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: Sat, 04 Jan 2014 21:24:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Thien-Thi Nguyen <ttn@gnu.org> 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...?

DWR = Design with Reuse?

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


reply via email to

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