Guest User

Untitled

a guest
Nov 15th, 2011
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.65 KB | None | 0 0
  1. (defun operation-p (x)
  2.   (or (equal x '+) (equal x '-) (equal x '*) (equal x '/)))
  3.  
  4. (defun clone (sexpr)
  5.   (cond
  6.     ((listp sexpr)
  7.      (if (null sexpr)
  8.        ()
  9.        (let ((hd (car sexpr))
  10.              (tl (cdr sexpr)))
  11.          (cond
  12.            ((listp hd) (append (list (clone hd)) (clone tl)))
  13.            ((operation-p hd) (list 'the 'fixnum (cons hd (clone tl))))
  14.            (t (cons hd (clone tl)))))))
  15.     (t sexpr)))
  16.  
  17. (defmacro fast (&rest sexpr)
  18.   `,(car (clone sexpr)))
  19.  
  20. (defun main ()
  21.   (progn
  22.     (format t "~A~%" (+ 1 2 (* 3 4) (+ 5 (- 8 6))))
  23.     (format t "~A~%" (fast (+ 1 2 (* 3 4) (+ 5 (- 8 6)))))))
  24.  
  25. (main)
  26. (quit)
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment