;;11/11/21 ;;this function will return the nth element in the list l. (defun pick (n l) ( cond ( (null l) l) ( (eq n 1) (car l)) ( t ( pick (- n 1) (cdr l))) ) ) (pick 1 '(4 5 6)) (pick 4 '(4 5 6)) ;;this function will return the leftmost atom in a given list l. (defun leftmost (l) ( cond ( (null l) l) ( (atom (car l)) (car l)) ( t (leftmost (car l))) ) ) (leftmost '(4 5 6)) (leftmost '( (4 5) 6 (3 4))) (leftmost '( ( (2 3) 4) 5 (6 7))) (leftmost '( ( (4) 5) 6 (3 4))) (cdr (cdr (cdr '(9 (3 5) (7 5 (3 4))) ) ) ) (set 'x 2) x (setq y 3) y x (+ x y) (* x y) (setq z (* x y)) z (car (list 3 4 'a 'b 6)) ( cond ( (> x 5) (+ x 1)) ( t (- x 1)) ) (if (not (or (> x 5) (< x 0))) (+ x 1) (- x 1)) (max 3 5) (apply '+ '(3 4 5)) ;;does not work. Invalid syntax. 3 4 5 need to be in a list --> '(3 4 5) (apply '+ 3 4 5) (setq op '*) (apply op '(3 4 5)) (setq op2 'max) (apply op2 '(3 6 9)) (numberp 4) (numberp 'a) (numberp '(3 4)) (numberp 100) ;;this function will return a list of the non-number members of the given list. (defun no-num (l) ( cond ( (null l) l) ( (numberp (car l)) (no-num (cdr l))) ( t (cons (car l) (no-num(cdr l)))) ) ) (no-num '(1 'a 'b 3 'flower)) (no-num '(5 'a 'b 'flower 100 15 'car))