2 ms·
> Aggressive duck typing means consistent syntax for different data structures and types. Stuff "just works" without a deep understanding of how it works. $
by kazinator 9y ago
> Aggressive duck typing means consistent syntax for different data structures and types. Stuff "just works" without a deep understanding of how it works.
$ txr
This is the TXR Lisp interactive listener of TXR 180.
Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
1> [mapcar succ "abc"]
"bcd"
2> [mapcar succ #(1 2 3)]
#(2 3 4)
3> [mapcar succ '(1 2 3)]
(2 3 4)
4> ["abc" 1]
#\b
5> ['(0 1 2) 1]
1
6> [#H(() (2 two) (1 one)) 1] ;; #H = hash literal
one
7> (car "abc")
#\a
8> (cdr "abc")
"bc"
9> (car "a")
#\a
10> (cdr "a")
nil
11> (ldiff "abcd" "cd")
"ab"
However, your understanding has to be deeper to grok how this works. It is simpler for mapcar to just reject strings and be described only as a list operation.
Common Lisp does have the the concept of sequences: a collection of generic operations over vectors, strings and lists. It just doesn't "go to town" with it. Common Lisp offers compilation to fast code. Really fast. Python-will-never-get-there fast.