_ is the variable. For example, [+ 1 _] is equivalent to (fn (_) (+ 1 _)):
arc> (map [+ 1 _] '(10 20 30)) (11 21 31)
:, ~, ., and !. The ~ character provides Boolean complement of a procedure; ~a is equivalent to (complement a)
arc> (~odd 3) nil arc> (~even 3) tThe
: character implements function composition; a:b is equivalent to (compose a b) and applies a to the result of applying b:
arc> (odd:sqrt 4) nil arc> (odd:sqrt 9) tThe syntax
a.b is equivalent to (a b). It is intended for structure access:
arc> (= x '(a b c d)) (a b c d) arc> x.2 cThe syntax
a!b is equivalent to (a 'b). It is intended for structure access where quoting is needed:
arc> (= tb (obj a 10 b 20 c 30)) #hash((c . 30) (a . 10) (b . 20)) arc> tb!a 10
>(eval '(+ 1 2))
3
>(apply + '(1 2))
3
>(ssexpand 'x:~y:z)
(compose x (complement y) z)
>(ssexpand '+.1.2)
((+ 1) 2)
>(ssexpand '+!1!2)
((+ (quote 1)) (quote 2))
>(ssexpand 'cons!a!b)
((cons (quote a)) (quote b))
>(ssyntax 'x:y)
t
>((compose sqrt:len) "abcd")
2
function.
>(map (complement odd) '(1 2 3 4 5))
(nil t nil t nil)
Copyright 2008 Ken Shirriff.