help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: some more material on the Lisp data/code psychedelia


From: Emanuel Berg
Subject: Re: some more material on the Lisp data/code psychedelia
Date: Sun, 05 Jan 2014 00:40:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

>> You can also use ‘last’ and ‘setcar’ (via ‘incf’)
>> for this: (defun increment-last (ls) (when ls (incf
>> (car (last ls))) ls)) Non-recursive means less stack
>> required for long forms.  Destructive style is
>> sketchy but the func is already squarely in DWR
>> territory...
>
> That's interesting:
>
> (setq *ls* '(1 2 3))
>
> (defun inc-last (ls) (when ls (incf (car (last ls)))
> ls) )
>
> (inc-last *ls*) *ls* ; => '(1 2 4) after the above line
>
> I wonder how the "destructiveness" can be used with
> respect to the rest of the demo...?

How about:

(defun change-me ()
  (incf (car (last (symbol-function 'change-me))))
  1)

(change-me) ; hit `C-x e' repeatedly here

Ironic thing is, first version, while not as good,
actually showed the duality in a cool way. The above
version just looks stiff, its purpose unclear.

-- 
underground experts united:
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]