unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* some more material on the Lisp data/code psychedelia
@ 2014-01-04 19:37 Emanuel Berg
  2014-01-04 20:13 ` Thien-Thi Nguyen
       [not found] ` <mailman.11016.1388866201.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Emanuel Berg @ 2014-01-04 19:37 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-17  1:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-04 19:37 some more material on the Lisp data/code psychedelia Emanuel Berg
2014-01-04 20:13 ` Thien-Thi Nguyen
     [not found] ` <mailman.11016.1388866201.10748.help-gnu-emacs@gnu.org>
2014-01-04 20:24   ` Emanuel Berg
2014-01-04 23:40     ` Emanuel Berg
2014-01-17  1:29       ` Emanuel Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).