elisp | clojure | python | |
---|---|---|---|
generation | number-sequence | range | range |
vector | vector | ⁅⁆ | |
make-vector make-list make-string | |||
length | count | len | |
indexing | elt nth aref | nth | ⁅⁆ |
aset setcar/nthcdr | - | ⁅⁆= | |
sorting | sort | sort | sorted |
reverse list | nreverse reverse | reverse | reversed reverse ⁅::-1⁆ |
append seqs | |||
lex numbers | notation |
(setq x1 (length '(1 2 3)))
(setq x2 (length [1 2 3]))
(setq x3 (length "123"))
(format "x1 = %s x2 = %s x3 = %s\n" x1 x2 x3)
(def x1 (count '(1 2 3)))
(def x2 (count [1 2 3]))
(def x3 (count "123"))
(print "x1 = " x1 "x2 = " x2 "x2 = " x3)
x1 = len([1, 2, 3])
x2 = len([1, 2, 3])
x3 = len("123")
print "x1 = ", x1, "x2 = ", x2, "x3 = ", x3
For lists only.
(setq x1 (nth 0 '(1 2 3)))
(format "x1 = %s" x1)
(setq x2 (aref [1 2 3] 0))
(setq x3 (aref "123" 0))
(format "x2 = %s x3 = %s\n" x2 x3)
(def x1 (nth '(1 2 3) 0))
(def x2 (nth [1 2 3] 0))
(def x3 (nth "123" 0))
(print "x1 = " x1 "x2 = " x2 "x2 = " x3)
x1 = [1, 2, 3][0]
x2 = [1, 2, 3][0]
x3 = "123"[0]
print "x1 = ", x1, "x2 = ", x2, "x3 = ", x3
For lists only.
(setq x1 '(1 2 3))
(setcar (nthcdr 0 x1) 9)
(format "x1 = %s" x1)
x1 = [1, 2, 3]
x1[0] = 9
print "x1 = ", x1
(def x1 (range 9))
(def x2 (range 1 9))
(def x3 (range 1 9 2))
(print "x1 = " x1 "x2 = " x2 "x2 = " x3)
x1 = range(9)
x2 = range(1, 9)
x3 = range(1, 9, 2)
print "x1 = ", x1, "x2 = ", x2, "x3 = ", x3
(setq x (vector 'foo 23 [bar baz] "spam"))
(format "x = %s" x)
(def x1 '(1 3 2 6 5 4 0))
(def x2 (sort > x1))
(print "x1 = " x1 "x2 = " x2)
x1 = [1, 3, 2, 6, 5, 4, 0]
x2 = sorted(x1, cmp=lambda x,y: x-y, reverse = True)
print "x1 = ", x1, "x2 = ", x2
x1 = ["a", "b", "c"]
x2 = [i for i in reversed(x1)]
print "x1 = ", x1, "x2 = ", x2
x1 = ["a", "b", "c"]
x1.reverse()
print "x1 = ", x1