You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(def range "start end" "Creates a list of numbers from start to end in steps of 1. The last number is <= end." (tests (range 0 10) (range 1.5 3.8)))
39
39
(mac n-of "n expr" "Evaluates <code>expr</code> <code>n</code> times and returns a list of the results." (tests (n-of 5 "a") (w/instring ins "abcdefg" (n-of 5 (readc ins)))))
40
40
(def adjoin "elt list [test]" "Cons <code>elt</code> onto <code>list</code> unless <code>(test elt y)</code> is true for some <code>y</code> in <code>list</code>. By default, <code>test</code> is <code>iso</code>, so <code>elt</code> will be joined if it is not present in <code>list</code>." (tests (adjoin 2 '(1 2 3)) (adjoin 2 '(1 3 5)) (adjoin 2 '(1 2 3) <) (adjoin 2 '(0 1 2) <)))
@@ -82,12 +82,11 @@
82
82
(text "These operations act on lists, strings, or hash tables.")
83
83
(op destructive sref "seq value index" "Sets indexed entry in a list, string, or hash table to
84
84
the given value."
85
-
(tests "(do
86
-
(= x \"abc\")
85
+
(tests "(let x (copy \"abc\") ; <span style='color:blue'>make the string literal mutable</span>
87
86
(sref x #\\d 1) x)"
88
87
"(do
89
88
(= x '(1 2 3))
90
-
(sref x #\\d 1) x)"))
89
+
(sref x 4 1) x)"))
91
90
(def count "test seq" "Counts the number of elements of <code>seq</code> that satisfy <code>test</code>. <code>test</code> is an object or predicate. For a table, the elements are the values." (tests (count #\a "banana") (count [odd _] '(1 2 3 4 5))) (count [odd _] (obj a 1 b 2 c 3)))
92
91
(def union "f xs ys" "Takes union of sequence <code>xs</code> and <code>ys</code>. Predicate <code>f</code> is used to determine equality to filter out duplicates. <code>xs</code> and <code>ys</code> must both be lists or strings." (tests
93
92
(union is '(1 2 3) '(2 3 4))
@@ -122,7 +121,7 @@ the sequences are identical." (tests (mismatch "abcde" "abXde") (mismatch '(1
(map (fn (c n) (coerce (+ n (coerce c 'int)) 'char)) "abc" '(0 2 4))
124
123
(map min "bird" "elephant")))
125
-
(def sum "f seq" "Applies f to the elements of the sequence and sums the results. New in arc3." (tests (sum int "abc") (sum log '(1 2 3)) (sum idfn (obj 'a 1 'b 2 'c 3))))
124
+
(def sum "f seq" "Applies f to the elements of the sequence and sums the results. New in arc3." (tests (sum int "abc") (sum log '(1 2 3)) (sum cadr (obj a 1 b 2 c 3))))
126
125
127
126
(def get "index" "Generates a function to get the element referenced by index; the function can be applied to a table. This is useful for mapping, for instance. (It can also be applied to functions, not jus sequences.) New in arc3."
128
127
(tests (map get.2 '((a b c) (1 2 3) (p q r))) (get!b (obj a 10 b 20)) (get.42 log)))
0 commit comments