| John Thingstad 2008-02-20, 4:48 am |
| I was messing around in LispWorks the other day and came up with this
lambda notation.
(mapcar λ(e) (+ e 10) '(1 2 3 4)
(I guess Kenny is right. I was supposed to be working on my BugTrack
program, but this was more fun..)
Warning: This contains LispWorks spesific code.
;;-*-mode: lisp; coding: utf-16;-*-
;; lambda notation using λ
;; Written: February 2008 John Thingstad ©
;;
;; use: (mapcar λ(e) (+ e 10) '(1 2 3 4)
;; (mapcar λ(a b) (+ a b)
;; (loop repeat 10 collect (random 10))
;; (loop for i from 0 upto 10 collect i))
;;
;; To enter λ type Control-Alt-l
;;
;; To use this in the editor you need a font that supports unicode
;; like "Lucida Console".
;; simple-char supports unicode unlike default base-char
(set-default-character-element-type 'simple-char)
;; reader: λ gets expanded to (lambda (read) (read))
(defun lambda-reader (stream char)
(declare (ignore char))
(list 'lambda
(read stream nil (values) t)
(read stream nil (values) t)))
(set-macro-character #\λ #'lambda-reader)
;; editor: control-l inserts λ in lisp mode
(editor:defcommand "Insert Lambda" (p)
(declare (ignore p))
(editor:insert-character (editor:current-point) #\λ))
(editor:bind-key "Insert Lambda" #\meta-\control-\l :mode "lisp")
--------------
John Thingstad
|