-
Notifications
You must be signed in to change notification settings - Fork 0
/
lists.lisp
69 lines (43 loc) · 905 Bytes
/
lists.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(List 1 2 3)
;; => (1 2 3)
(cons 4 (list 1 2 3))
;; => (4 1 2 3)
(cons 1 ())
;; => (1)
(cons 1 (cons 2 ()))
;; => (1 2)
(first (list 7 8 9))
;; => 7
(last (list 8 5 "foobar"))
;; => ("foobar")
(first (last (list "Chris" "Alex" "Dave")))
;; => "Dave"
(rest (list 1 2 3))
;; => (2 3)
(third (list 1 2))
;; => NIL
(nth 3 (list 3 4 5 6))
;; => 6
(append (list 1 2 3) (list 4 5 6))
;; => (1 2 3 4 5 6)
(butlast (list 1 2 3))
;; => (1 2)
(subseq (list "a" "b" "c" "d" "e" "f") 1 3)
;; => ("b" "c")
(subseq (list "a" "b" "c" "d" "e" "f") 3)
;; => ("d" "e" "f")
(subseq (list 1 2 3) 0 1337)
;; WILL BLOW UP WITH LEETNESS
(length (list 1 2 3 4 5 6))
;; => 6
(reverse (list 6 5 4 3 2 1))
;; => (1 2 3 4 5 6)
;; ELITE LEVEL
(car (list 1 2 3))
;; => 1
(cdr (list 1 2 3))
;; => (2 3)
(caddar (list (list 1 2 3 4) (list 5 6 7 8)))
;; => 3
(cadadr (list (list 1 2 3 4) (list 5 6 7 8)))
;; => 6