On Wed, Dec 28, 2022 at 01:32:52AM +0100, Emanuel Berg wrote: > Why doesn't this work? > > For sure, there is a mistake somewhere but it seems now matter how > I change it I get the same result ... > > ;;; -*- lexical-binding: t -*- > ;; > ;; this file: > ;; https://dataswamp.org/~incal/emacs-init/mvc/model.el > > (require 'cl-lib) > > (defun make-world (dim len &optional init) > (or init (setq init ".")) > (if (zerop dim) > init > (make-list len (make-world (1- dim) len init)) )) Heh. When you are making a higher-order world, you are storing a ref to the same list in each of its slots. So if you change something at a lower level *poof* all are changed. Read the subsection "samenes and change" in 3.1 of SICP [1] for a beautiful treatment (actually, re-read SICP: a beautiful book) Oh, I nearly forgot: if you want it to work, you'll have to regenerate the lower-level worlds (or deep copy them). Cheers [1] https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-20.html (Sorry: fragment links seem to be disfunctional) -- t