Created
May 7, 2010 11:37
-
-
Save youz/393310 to your computer and use it in GitHub Desktop.
short aliases for lambda expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; ref. http://blog.practical-scheme.net/gauche/20100428-shorter-names | |
;;; http://d.hatena.ne.jp/higepon/20100511/1273584001 | |
#+:xyzzy | |
(require 'cmu_loop) | |
(defmacro ^ (args . body) | |
`(lambda ,args ,@body)) | |
(defmacro define-caret-macros (chars) | |
(flet ((reread (&rest args) | |
(read-from-string (format nil "~{~A~}" args)))) | |
`(progn | |
,@(loop for c across chars | |
for macsym = (reread '^ c) | |
for argsym = (reread c) | |
for macsym* = (reread '^ c '*) | |
for argsym* = (reread c '*) | |
collect | |
`(defmacro ,macsym (&body body) | |
(let ((#1=#:arg ',argsym)) | |
`(lambda (,#1#) ,@body))) | |
collect | |
`(defmacro ,macsym* (&body body) | |
(let ((#1# ',argsym*)) | |
`(lambda (&rest ,#1#) ,@body))))))) | |
(define-caret-macros | |
"_abcdefghijklmnopqrstuvwxyz") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment