The hyperspec says it evaluates the expression in the current dynamic environment, but the null lexical environment. Thus: (defparameter z 666) ; z is dynamicly scoped (let ((z 14)) (eval '(setf www z))) www ==> 14 Since z is dynamicly scoped and not lexical. So what let is shadowing is important.
Hi, Thanks to all of you for your responses. One thing I forgot to mention in the original question is that I am using this function in a loop and using the built-in sort after adding each element(as I needed the sorted list for the next iteration as well) sounded inefficient to me. So you add to a...
Konfusius's is the fastes judging by my test which adds 1000 random numbers to an empty list. WIth a litte change to the tail recusive version it matches it: (defun sort-push-iter(lst n &key (test #'<) (key #'identity)) (labels ((rec (lst n acc) (if (null lst) (nreverse (cons n acc)) (if (funcal...
When I'm looking at that I'm thinking stack machine and parameters on stack. In that case the name of the variable is irellevant but it's order is. Would you consider these two the same as well? (defun add1 (x y) (+ x y)) ;; (clambda 2 (apply #+)) (defun add2 (x y) (+ y x)) ;; (clambda 2 (swap) (app...
push and pop are actually macroes: (macroexpand-1 '(push 'd x)) ==> (SETQ X (CONS 'D X)) ; (macroexpand '(pop x)) ==> (LET ((TMP-1 (CAR X))) (SETQ X (CDR X)) TMP-1) As you suspected CL doesn't change the target but makes a new list and associate X with that instead. Y still points to the same value ...
Wvxvw assumes you found answ3 only. It seems like you have done search prior to your insert? If you changed your search function to include the parent the insert would be trivial. You could return the parent as a second return value in your search with (values ans ans-parent) and do search for updat...
The reading I have got solved, the issue is printing lisp-objects in my syntax by the standard print function, so REPL returns results in my syntax. If I understand you correctly your reader reads {} as () so that ANY place in an expression it could be entered as curlies. You can overload print, bu...
If you know exactly where there are curlies and where there are normal parenthesis such that the structure makes it obvious you can just make a function my-print to deal with it. If there is no way of knowing where the curlies are they are kind of like how Racket reads all types of brackets. (Yes, I...