-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathassignment.tem
48 lines (47 loc) · 2.96 KB
/
assignment.tem
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
(page "Assignment"
(import "docs/assign.html")
(newtable "Summary"
(op destructive assign "symbol expr" "assign is used to assign a value to a variable. Renamed from <code>set</code> in arc3." (tests (assign x 10)))
(op destructive scar "list expr" "Assigns an expression to the car of list. If applied to a
string, assigns to the first character of the string, which must have length at
least one."
(tests "(do
(= x (copy \"abc\"))
(scar x #\\d)
x)"
"(do
(= x '(1 2 3))
(scar x #\\d)
x)"))
(op destructive scdr "list exp" "Assigns to cdr of a list."
(tests "(do
(= x '(1 2 3))
(scdr x '(4))
x)"))
(mac destructive = "[place expr] ... [place]" "Assigns to each place to the associated expression. If the last place has no associated expression, it is set to nil." (tests (= x 1) (= x 2 y 4)))
(mac destructive wipe "[place ...]" "Assigns nil to the places. Typically, the places are simple variables." (tests (do (wipe a b c) (list a b c))))
(mac destructive set "[place ...]" "Assigns t to the places. Renamed from assert in arc3." (tests (do (set a b c) (list a b c))))
(mac destructive swap "place1 place2" "The contents of the two places are swapped. The new contents of <code>place2</code> are returned."
(tests "(with (x 'a y '(1 2))
(swap x y)
(prn \"x:\" x)
y)"))
(mac destructive rotate "[place1 place2 ...]" "Assigns <i>place2</i> to <i>place1</i>, assigns <i>place3</i> to </i>place2</i>, and so on, assigning <i>place1</i> to the last place." (tests (let s (copy "abc") (rotate (s 0) (s 1) (s 2)) s)))
(mac destructive ++ "place [i]" "Increments the value at <code>place</code> by <code>i</code>. The default increment is 1." (tests (let x '(10 20) (++ (car x)) (++ (x 1) 5) x)))
(mac destructive -- "place [i]" "Decrements the value at <code>place</code> by <code>i</code>. The default decrement is 1." (tests (let x '(10 20) (-- (car x)) (-- (x 1) 5) x)))
(mac destructive zap "op place [args ...]" "Gets the value at the place, evaluates <code>(op <i>value args...</i>)</code>, and stores the result in the place." (tests
(let x '(0 10 20) (zap * (x 1) 5) x)
))
(mac destructive push "elt place" "Pushes an element at the beginning of the list referenced by place. The list is modified and returned."
(tests (let x '(1 2 3) (push 'a x) x)))
(mac destructive pushnew "elt place [test]" "Pushes <code>elt</code> before the place if it is not present in the list. The equality test can be specified; <code>iso</code> is used by default. " (tests
(let x '(1 2 3) (pushnew 'a x) x)
(let x '(1 2 3) (pushnew 2 x) x)))
(mac destructive pop "place" "The first element is removed from place and returned. If the value at the place is nil, then nil is returned."
(tests "(let x '(1 2 3)
(prn \"Popped:\" (pop x))
x)"))
(mac destructive pull "test place" "Remove elements satisfying <code>test</code> from the list starting at <code>place</code>." (tests "(let x '(1 100 2 50 3) (pull [< _ 10] x) x)"))
)
(import "docs/legend.html")
)