lisp - Change variable defined in let function -


given following let function:

(let ((foo (list b c d))) foo) 

how can modify list foo?

(let ((foo (list b c d))) ;some code foo) 

so returned foo looks eks: '(some new list) or (a b modified d)

i tried (set) foo still return original list.

you can use setf modify specific element in list.

(let ((foo (list 'a 'b 'c 'd)))   (setf (third foo) 'modified)   foo) 

this return (a b modified d).

or if want replace whole variable, can assign directly setq:

(let ((foo (list 'a 'b 'c 'd)))   (setq foo (list 'some 'new 'list))   foo) 

you can't use set lexical variables, special variables.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -