Code: Select all
> (flat '('(1 2) (3 4)))
('(1 2) 3 4)
Code: Select all
> (flat '('(1 2) (3 4)))
('(1 2) 3 4)
Code: Select all
cljs.user> (flatten '('(1 2) (3 4)))
(quote 1 2 3 4)
Code: Select all
(defun flatten (obj)
(do* ((result (list obj))
(node result))
((null node) (delete nil result))
(cond ((consp (car node))
(when (cdar node) (push (cdar node) (cdr node)))
(setf (car node) (caar node)))
(t (setf node (cdr node))))))
Code: Select all
(list? (nth 0 '('(1 2) (3 4)))) ; --> nil (id est, false)
Code: Select all
(quote? (nth 0 '('(1 2) (3 4)))) ; --> true
Code: Select all
> (length (lambda)) ; the lambda indicates, it’s a lambda list
0
> (lambda) ; lambda is not a symbol, lambda lists evaluate to themselves
(lambda )
> (list? (lambda))
true
> (lambda? (lambda)) ; a lambda list is a sub-type of the list type
true
Code: Select all
> (append (lambda) '((x) (+ x x)))
(lambda (x) (+ x x))
> (set 'double (append (lambda) '((x) (+ x x)))) ; same as using define
(lambda (x) (+ x x))
> (double 123)
246