2 ms·
(reduce #'- (reverse (list 1 2 3))) You can use: (reduce (function -) (reverse (list 1 2 3))) or (reduce '- (reverse (list 1 2 3))) Then (mapc
by lispm 11y ago
(reduce #'- (reverse (list 1 2 3)))
You can use:
(reduce (function -) (reverse (list 1 2 3)))
or
(reduce '- (reverse (list 1 2 3)))
Then
(mapcar #'string-downcase (list "Hello" "world!"))
Use:
(map 'list #'string-downcase (list "Hello" "world!"))
> Make-instance? It's called new in C# and Java which is 3 keystrokes,
Slightly advanced users type m - i complete.
If you want to call it 'new', then just add 'new'. Common Lisp is extensible.
CL-USER 32 > (defclass a () ((b :initarg :b)))
#<STANDARD-CLASS A 4020124173>
CL-USER 33 > (setf (symbol-function 'new) #'make-instance)
#<STANDARD-GENERIC-FUNCTION MAKE-INSTANCE 4100096004>
CL-USER 34 > (new 'a :b 10)
#<A 4020133143>
Hashtables, since Common Lisp is a programmable language, that syntax is user extensible. Example:
CL-USER 42 > (defparameter *h* #{(a 5) (c 6) (b 3)})
*H*
CL-USER 43 > *h*
#{(C 6) (B 3) (A 5)}