Attempt to made a more alisp compatibel append:
(define (append-nil alist )
(if alist
(begin
(setq _nlst alist)
(dolist (_lst (args))(setq _nlst(append _nlst _lst))))
(begin
(setq _nlst (list ))
(dolist (_lst (args))(setq _nlst(append _nlst _lst))))
))
> (setq a '(1 2))
(1 2)
> (append-nil a '(3)'(4)'(5))
(1 2 3 4 5)
> (append-nil b '(3)'(4)'(5))
(3 4 5)
>
Any better solution?
Use 'apply append' instead of 'dolist':
(define (append-nil alist)
(if alist (append alist (apply append (args)))
(apply append (args))))
Lutz
Thanks a lot. I have still the problem, to get the brain more lispisch.
;-)
we can make it even shorter:
(define (append-nil alist)
(append (if alist alist '()) (apply append (args))))
Lutz