Some syntactic sugar for Scsh (or
Scheme48).
One of the features in the wish list of Arc that I found
cool was the square bracket sexp that expands to a single
argument lambda expression. So that one can do things like:
(map [/ _ 2] '(2 4 6 8 10))
(cond ((regexp-exec re str) => [match:substring _ 1]) ...)
instead of
(map (lambda (x) (/ x 2)) '(2 4 6 8 10))
(cond ((regexp-exec re str) => (lambda (m) (match:substring m 1))) ...)
Disclaimer: I am not advocating Perl-ish syntactic crypticism.
This has been written just as a funny exercise in Scsh
hacking.
Here is a less heretic approach for those using
Emacs:
(defun lisp-insert-lambda ()
"Insert lambda form at point asking for variables."
(interactive)
(insert "(lambda (" (read-string "Variables: ") ") ")
(save-excursion (insert ")")))
(add-hook 'scheme-mode-hook
'(lambda ()
(local-set-key "\C-cl" 'lisp-insert-lambda)))