(defvar x (list 1 2 3 4 5)) (defvar y (list 6 7 8 9 10)) (defvar z (list 11 12)) (defun list_reference (items n) (if (= n 0) (car items) (list_reference (cdr items) (- n 1)) ) ) (defun list_length (items) (if (null items) 0 (+ 1 (list_length (cdr items)))) ) (defvar w (list (list 1 2) (list 3 4))) (defun count_leaves (tree) (if (null tree) 0 (if (not (listp tree)) 1 (+ (count_leaves(car tree)) (count_leaves(cdr tree))) ) ) ) (defun count_leaves (tree) (if (null tree) 0 (if (not (listp tree)) 1 (+ (count_leaves(car tree)) (count_leaves(cdr tree))) ) ) ) (defun deep_reverse (_list) (if (null _list) _list (if (listp (car _list)) (_append(deep_reverse(cdr _list)) (list(deep_reverse (car _list)))) (_append(deep_reverse(cdr _list)) (list (car _list))) ) ) ) (defun _append(list_1 list_2) (if (null list_1) list_2 (cons (car list_1) (_append (cdr list_1) list_2))) ) (defun reverse_list (_list) (if (null _list) _list (_append(reverse_list (cdr _list)) (list (car _list)))) ) (print (reverse_list w)) (print (deep_reverse w))
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more