|
|
|
|
@ -39,6 +39,11 @@ |
|
|
|
|
(--map-when (= it 2) 17 '(1 2 3 4)) => '(1 17 3 4) |
|
|
|
|
(-map-when (lambda (n) (= n 3)) (lambda (n) 0) '(1 2 3 4)) => '(1 2 0 4)) |
|
|
|
|
|
|
|
|
|
(defexamples -replace |
|
|
|
|
(-replace 1 "1" '(1 2 3 4 3 2 1)) => '("1" 2 3 4 3 2 "1") |
|
|
|
|
(-replace "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo")) => '("a" "nice" "bar" "sentence" "about" "bar") |
|
|
|
|
(-replace 1 2 nil) => nil) |
|
|
|
|
|
|
|
|
|
(defexamples -map-indexed |
|
|
|
|
(-map-indexed (lambda (index item) (- item index)) '(1 2 3 4)) => '(1 1 1 1) |
|
|
|
|
(--map-indexed (- it it-index) '(1 2 3 4)) => '(1 1 1 1)) |
|
|
|
|
@ -108,49 +113,49 @@ |
|
|
|
|
|
|
|
|
|
(defexamples -insert-at |
|
|
|
|
(-insert-at 1 'x '(a b c)) => '(a x b c) |
|
|
|
|
(-insert-at 12 'x '(a b c)) => '(a b c x))) |
|
|
|
|
|
|
|
|
|
(defexamples -replace-at |
|
|
|
|
(-replace-at 0 9 '(0 1 2 3 4 5)) => '(9 1 2 3 4 5) |
|
|
|
|
(-replace-at 1 9 '(0 1 2 3 4 5)) => '(0 9 2 3 4 5) |
|
|
|
|
(-replace-at 4 9 '(0 1 2 3 4 5)) => '(0 1 2 3 9 5) |
|
|
|
|
(-replace-at 5 9 '(0 1 2 3 4 5)) => '(0 1 2 3 4 9)) |
|
|
|
|
|
|
|
|
|
(defexamples -update-at |
|
|
|
|
(-update-at 0 (lambda (x) (+ x 9)) '(0 1 2 3 4 5)) => '(9 1 2 3 4 5) |
|
|
|
|
(-update-at 1 (lambda (x) (+ x 8)) '(0 1 2 3 4 5)) => '(0 9 2 3 4 5) |
|
|
|
|
(--update-at 2 (length it) '("foo" "bar" "baz" "quux")) => '("foo" "bar" 3 "quux") |
|
|
|
|
(--update-at 2 (concat it "zab") '("foo" "bar" "baz" "quux")) => '("foo" "bar" "bazzab" "quux")) |
|
|
|
|
|
|
|
|
|
(defexamples -remove-at |
|
|
|
|
(-remove-at 0 '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4" "5") |
|
|
|
|
(-remove-at 1 '("0" "1" "2" "3" "4" "5")) => '("0" "2" "3" "4" "5") |
|
|
|
|
(-remove-at 2 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "3" "4" "5") |
|
|
|
|
(-remove-at 3 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "4" "5") |
|
|
|
|
(-remove-at 4 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "5") |
|
|
|
|
(-remove-at 5 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "4") |
|
|
|
|
(-remove-at 5 '((a b) (c d) (e f g) h i ((j) k) l (m))) => '((a b) (c d) (e f g) h i l (m)) |
|
|
|
|
(-remove-at 0 '(((a b) (c d) (e f g) h i ((j) k) l (m)))) => nil) |
|
|
|
|
|
|
|
|
|
(defexamples -remove-at-indices |
|
|
|
|
(-remove-at-indices '(0) '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4" "5") |
|
|
|
|
(-remove-at-indices '(0 2 4) '("0" "1" "2" "3" "4" "5")) => '("1" "3" "5") |
|
|
|
|
(-remove-at-indices '(0 5) '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4") |
|
|
|
|
(-remove-at-indices '(1 2 3) '("0" "1" "2" "3" "4" "5")) => '("0" "4" "5") |
|
|
|
|
(-remove-at-indices '(0 1 2 3 4 5) '("0" "1" "2" "3" "4" "5")) => nil |
|
|
|
|
(-remove-at-indices '(2 0 4) '("0" "1" "2" "3" "4" "5")) => '("1" "3" "5") |
|
|
|
|
(-remove-at-indices '(5 0) '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4") |
|
|
|
|
(-remove-at-indices '(1 3 2) '("0" "1" "2" "3" "4" "5")) => '("0" "4" "5") |
|
|
|
|
(-remove-at-indices '(0 3 4 2 5 1) '("0" "1" "2" "3" "4" "5")) => nil |
|
|
|
|
(-remove-at-indices '(1) '("0" "1" "2" "3" "4" "5")) => '("0" "2" "3" "4" "5") |
|
|
|
|
(-remove-at-indices '(2) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "3" "4" "5") |
|
|
|
|
(-remove-at-indices '(3) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "4" "5") |
|
|
|
|
(-remove-at-indices '(4) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "5") |
|
|
|
|
(-remove-at-indices '(5) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "4") |
|
|
|
|
(-remove-at-indices '(1 2 4) '((a b) (c d) (e f g) h i ((j) k) l (m))) => '((a b) h ((j) k) l (m)) |
|
|
|
|
(-remove-at-indices '(5) '((a b) (c d) (e f g) h i ((j) k) l (m))) => '((a b) (c d) (e f g) h i l (m)) |
|
|
|
|
(-remove-at-indices '(0) '(((a b) (c d) (e f g) h i ((j) k) l (m)))) => nil |
|
|
|
|
(-remove-at-indices '(2 3) '((0) (1) (2) (3) (4) (5) (6))) => '((0) (1) (4) (5) (6))) |
|
|
|
|
(-insert-at 12 'x '(a b c)) => '(a b c x)) |
|
|
|
|
|
|
|
|
|
(defexamples -replace-at |
|
|
|
|
(-replace-at 0 9 '(0 1 2 3 4 5)) => '(9 1 2 3 4 5) |
|
|
|
|
(-replace-at 1 9 '(0 1 2 3 4 5)) => '(0 9 2 3 4 5) |
|
|
|
|
(-replace-at 4 9 '(0 1 2 3 4 5)) => '(0 1 2 3 9 5) |
|
|
|
|
(-replace-at 5 9 '(0 1 2 3 4 5)) => '(0 1 2 3 4 9)) |
|
|
|
|
|
|
|
|
|
(defexamples -update-at |
|
|
|
|
(-update-at 0 (lambda (x) (+ x 9)) '(0 1 2 3 4 5)) => '(9 1 2 3 4 5) |
|
|
|
|
(-update-at 1 (lambda (x) (+ x 8)) '(0 1 2 3 4 5)) => '(0 9 2 3 4 5) |
|
|
|
|
(--update-at 2 (length it) '("foo" "bar" "baz" "quux")) => '("foo" "bar" 3 "quux") |
|
|
|
|
(--update-at 2 (concat it "zab") '("foo" "bar" "baz" "quux")) => '("foo" "bar" "bazzab" "quux")) |
|
|
|
|
|
|
|
|
|
(defexamples -remove-at |
|
|
|
|
(-remove-at 0 '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4" "5") |
|
|
|
|
(-remove-at 1 '("0" "1" "2" "3" "4" "5")) => '("0" "2" "3" "4" "5") |
|
|
|
|
(-remove-at 2 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "3" "4" "5") |
|
|
|
|
(-remove-at 3 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "4" "5") |
|
|
|
|
(-remove-at 4 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "5") |
|
|
|
|
(-remove-at 5 '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "4") |
|
|
|
|
(-remove-at 5 '((a b) (c d) (e f g) h i ((j) k) l (m))) => '((a b) (c d) (e f g) h i l (m)) |
|
|
|
|
(-remove-at 0 '(((a b) (c d) (e f g) h i ((j) k) l (m)))) => nil) |
|
|
|
|
|
|
|
|
|
(defexamples -remove-at-indices |
|
|
|
|
(-remove-at-indices '(0) '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4" "5") |
|
|
|
|
(-remove-at-indices '(0 2 4) '("0" "1" "2" "3" "4" "5")) => '("1" "3" "5") |
|
|
|
|
(-remove-at-indices '(0 5) '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4") |
|
|
|
|
(-remove-at-indices '(1 2 3) '("0" "1" "2" "3" "4" "5")) => '("0" "4" "5") |
|
|
|
|
(-remove-at-indices '(0 1 2 3 4 5) '("0" "1" "2" "3" "4" "5")) => nil |
|
|
|
|
(-remove-at-indices '(2 0 4) '("0" "1" "2" "3" "4" "5")) => '("1" "3" "5") |
|
|
|
|
(-remove-at-indices '(5 0) '("0" "1" "2" "3" "4" "5")) => '("1" "2" "3" "4") |
|
|
|
|
(-remove-at-indices '(1 3 2) '("0" "1" "2" "3" "4" "5")) => '("0" "4" "5") |
|
|
|
|
(-remove-at-indices '(0 3 4 2 5 1) '("0" "1" "2" "3" "4" "5")) => nil |
|
|
|
|
(-remove-at-indices '(1) '("0" "1" "2" "3" "4" "5")) => '("0" "2" "3" "4" "5") |
|
|
|
|
(-remove-at-indices '(2) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "3" "4" "5") |
|
|
|
|
(-remove-at-indices '(3) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "4" "5") |
|
|
|
|
(-remove-at-indices '(4) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "5") |
|
|
|
|
(-remove-at-indices '(5) '("0" "1" "2" "3" "4" "5")) => '("0" "1" "2" "3" "4") |
|
|
|
|
(-remove-at-indices '(1 2 4) '((a b) (c d) (e f g) h i ((j) k) l (m))) => '((a b) h ((j) k) l (m)) |
|
|
|
|
(-remove-at-indices '(5) '((a b) (c d) (e f g) h i ((j) k) l (m))) => '((a b) (c d) (e f g) h i l (m)) |
|
|
|
|
(-remove-at-indices '(0) '(((a b) (c d) (e f g) h i ((j) k) l (m)))) => nil |
|
|
|
|
(-remove-at-indices '(2 3) '((0) (1) (2) (3) (4) (5) (6))) => '((0) (1) (4) (5) (6)))) |
|
|
|
|
|
|
|
|
|
(def-example-group "Reductions" nil |
|
|
|
|
(defexamples -reduce-from |
|
|
|
|
|