from source-code CLISP-2.38
- From: "arnuld" <arnuld3@xxxxxxxxx>
- Date: 29 Jun 2006 10:46:46 -0700
hai folks
i was browsing through the source-code of CLISP 2.38, in the file named
"LOOP.lisp" i came across the following function:
(defun destructure-vars (pattern)
(let ((vars '()))
(labels ((accumulate (pattern)
(cond ((null pattern))
((atom pattern) (push pattern vars))
(t
(accumulate (car pattern))
(accumulate (cdr pattern))))))
(accumulate pattern))
(nreverse vars)))
;; OUTPUT
(destructure-vars '(1 2 3 4)) ==> '(1 2 3 4)
(destructure-vars '(1 (((2))) (((3)) 4))) ==> '(1 2 3 4)
ok i got it this function destructures the elements of a tree into a
single list, BUT, then i took out "accumulate" from the "labels" and
tried it as a stand-alone function.
(defun accumulate (pattern)
(let ((vars '()))
(cond ((null pattern))
((atom pattern) (push pattern vars))
(t (accumulate (car pattern))
(accumulate (cdr pattern))))
(nreverse vars)))
;; OUTPUT
(accumulate '(1 2 3 4)) ==> NIL
(accumulate '(1 (((2))) (((3)) 4))) ==> NIL
why it does not produce '(1 2 3 4) even though it's same (only "labels"
is not here)
why two same functions are producing different outputs?
how can i make 2nd one to produce same output as 1st one. i have Debian
"Sarge" running with CLISP - 2.33.2. (i also have SBCL 0.9.11)
thanks
-- arnuld
.
- Follow-Ups:
- Re: from source-code CLISP-2.38
- From: micromoog
- Re: from source-code CLISP-2.38
- Prev by Date: Re: What would a modern LispOS look like?
- Next by Date: Re: What would a modern LispOS look like?
- Previous by thread: LISP code example matching an abstract construct
- Next by thread: Re: from source-code CLISP-2.38
- Index(es):
Relevant Pages
|