Advertisement
TukieEz

Untitled

May 5th, 2023
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.04 KB | None | 0 0
  1. (print(apply '+ '(33 56))); (+ 33 56)
  2. (print (funcall 'cons '(a b) 'c)); (cons '(a b) 'c)
  3. (print(mapl 'cons '(apply funcall) '(3)))
  4. (print(funcall 'apply 'list '(a (a b))))
  5. (print (progn
  6.            (setq b 6)
  7.            (atom `(car(a ,b)))
  8.        )
  9. )
  10. (print (funcall '+ '33 '56))
  11. (print (apply 'cons '((a b) c)))
  12. ;2
  13. (setq x '(1 2 3 (1 2 3 4 5) 5 6))
  14. (setq f '(+ member *))
  15.  
  16. (defun aapply (f x)
  17.     (cond
  18.         ((null x) nil)
  19.         (t(cons(apply (car f) (list (car x) (cadr x))) (aapply (cdr f) (cddr x))))
  20.     )
  21. )
  22. (print (aapply f x))
  23.  
  24.  
  25. ;3
  26. (setq pr 'numberp)
  27. (setq ls '(4 2 f 2 8 h 3 j 0 9 s))
  28.  
  29. (defun every_m3 (pr ls)
  30.     (cond ((null ls) T)
  31.         (t(and(funcall pr (car ls)) (every_m3 pr (cdddr ls))))
  32.     )
  33. )
  34.  
  35. (print (every_m3 pr ls))
  36.  
  37. ;4
  38. (setq fn '-)
  39. (setq x '((1 2) (3 4 5)))
  40.  
  41. (defun map-car (fn x)
  42.     (cond ((null x) nil)
  43.         ((atom (car x))(cons (funcall fn (car x)) (map-car fn (cdr x))))
  44.         ((listp (car x))(cons (apply fn (car x)) (map-car fn (cdr x))))
  45.     )
  46. )
  47. (print ( map-car fn x))
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement