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

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

some more material on the Lisp data/code psychedelia


From: Emanuel Berg
Subject: some more material on the Lisp data/code psychedelia
Date: Sat, 04 Jan 2014 20:37:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

The whole discussion on types and the Lisp data/code
blend was the source of some confusion. But perhaps
that's nothing to be ashamed of.

I thought it would be clearer if I could turn it into
actual code. So if you don't mind, please comment on
this.

(defun increment-last (l)
  (interactive)
  (if (not l) '()
    (let ((hd (car l))
          (tl (cdr l)) )
      (if (not tl)
          (list (+ 1 hd))
        (cons hd (increment-last tl) )))))

;; test
(increment-last '())       ; => '()
(increment-last '(1))      ; => '(2)
(increment-last '(1 2 3))  ; => '(1 2 4)

(defun do-change-me ()
  (interactive)
  (fset 'do-change-me
        (increment-last (symbol-function 'do-change-me)) )
  1)

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

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


reply via email to

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