Thomas Morley <thomasmorle...@googlemail.com> writes: > Hi, > > the following code gives me the expected output in guile: > > (define-public lst `()) > (define (set-new-alist! ls-1 ls-2 proc) > (for-each (lambda (x) (set! ls-1 (acons x proc ls-1))) ls-2) > ls-1) > (set-new-alist! lst '(1 2 3) "X") > > ==> ((3 . "X") (2 . "X") (1 . "X")) > > trying similiar in lily: > > \version "2.15.36" > > #(define-public lst `()) > #(define (set-new-alist! ls-1 ls-2 proc) > (for-each (lambda (x) (set! ls-1 (acons x proc ls-1))) ls-2) > ls-1) > #(set-new-alist! lst '(1 2 3) "X") > #(display lst) > > returns: () > > What am I missing?
There is no discrepancy. If you write (display lst) after the first case, it will also show just (). In either case, set-new-alist! returns the value shown above, and lst is left unchanged. Lisp is call-by-value. -- David Kastrup _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel