(defmacro schemish (functions &body body)
`(macrolet ,(mapcar (lambda (function)
`(,function (&rest args)
`(funcall ,',function ,@args)))
functions)
,@body))
(print (macroexpand '(schemish (fun) (fun 42))))
(defun best (fun list)
(schemish (fun)
(reduce (lambda (x y) (if (fun x y) x y))
list)))
(print (macroexpand '(schemish (fun)
(reduce (lambda (x y) (if (fun x y) x y))
list))))
(print (best #'> '(1 2 3 4 5 -1)))
(print (best '< '(1 2 3 4 5 -1)))
KGRlZm1hY3JvIHNjaGVtaXNoIChmdW5jdGlvbnMgJmJvZHkgYm9keSkKICAgICAgYChtYWNyb2xldCAsKG1hcGNhciAobGFtYmRhIChmdW5jdGlvbikKICAgICAgICAgICAgICAgICAgICBgKCxmdW5jdGlvbiAoJnJlc3QgYXJncykKICAgICAgICAgICAgICAgICAgICAgICBgKGZ1bmNhbGwgLCcsZnVuY3Rpb24gLEBhcmdzKSkpCiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb25zKQogICAgICAgIAogICAgICAgICAgLEBib2R5KSkKCihwcmludCAobWFjcm9leHBhbmQgJyhzY2hlbWlzaCAoZnVuKSAoZnVuIDQyKSkpKQoKKGRlZnVuIGJlc3QgKGZ1biBsaXN0KQogIChzY2hlbWlzaCAoZnVuKQogICAgKHJlZHVjZSAobGFtYmRhICh4IHkpIChpZiAoZnVuIHggeSkgeCB5KSkKICAgICAgICAgICAgbGlzdCkpKQoKKHByaW50IChtYWNyb2V4cGFuZCAnKHNjaGVtaXNoIChmdW4pCiAgICAgICAgKHJlZHVjZSAobGFtYmRhICh4IHkpIChpZiAoZnVuIHggeSkgeCB5KSkKICAgICAgICAgICAgICAgIGxpc3QpKSkpCgoocHJpbnQgKGJlc3QgIyc+ICcoMSAyIDMgNCA1IC0xKSkpCgoocHJpbnQgKGJlc3QgJzwgJygxIDIgMyA0IDUgLTEpKSkKCgoK