fork(11) download
  1. (defmacro schemish (functions &body body)
  2. `(macrolet ,(mapcar (lambda (function)
  3. `(,function (&rest args)
  4. `(funcall ,',function ,@args)))
  5. functions)
  6.  
  7. ,@body))
  8.  
  9. (print (macroexpand '(schemish (fun) (fun 42))))
  10.  
  11. (defun best (fun list)
  12. (schemish (fun)
  13. (reduce (lambda (x y) (if (fun x y) x y))
  14. list)))
  15.  
  16. (print (macroexpand '(schemish (fun)
  17. (reduce (lambda (x y) (if (fun x y) x y))
  18. list))))
  19.  
  20. (print (best #'> '(1 2 3 4 5 -1)))
  21.  
  22. (print (best '< '(1 2 3 4 5 -1)))
  23.  
  24.  
  25.  
  26.  
Success #stdin #stdout 0.02s 10608KB
stdin
Standard input is empty
stdout
(MACROLET ((FUN (&REST ARGS) (CONS 'FUNCALL (CONS 'FUN ARGS)))) (FUN 42)) 
(MACROLET ((FUN (&REST ARGS) (CONS 'FUNCALL (CONS 'FUN ARGS))))
 (REDUCE (LAMBDA (X Y) (IF (FUN X Y) X Y)) LIST)) 
5 
-1