on master help sign in
Make documentation of ++spin more accurate. (#853)
e1445e2David Osborne
reference/library/2b.md+17−17
@@ -1046,23 +1046,23 @@ A list
1046
1046
1047Gate to list, with state
1047Gate to list, with state
1048
1048
1049−Accepts a `++list` `a`, a gate `b`, and some state `c`. Produces a list with
1049+Accepts a `++list` `a`, some state `b`, and a gate `c`. `c` is called with
1050−the gate applied to each element of the original list. `b` is called with
1051−a tuple -- the head is an element of `a` and the tail is the state `c`, and
1050+a tuple -- the head is an element of `a` and the tail is the state `b`, and
1052should produce a tuple of the transformed element and the (potentially
1051should produce a tuple of the transformed element and the (potentially
1053−modified) state `c`.
1052+modified) state `b`. Produces a pair where the first element is a list of the
1053+transformed elements of `a`, and the second element is the final value of `b`.
1054
1054
1055#### Accepts
1055#### Accepts
1056
1056
1057`a` is a `++list`.
1057`a` is a `++list`.
1058
1058
1059−`b` is a gate.
1059+`b` is a noun.
1060
1060
1061−`c` is a noun.
1061+`c` is a gate.
1062
1062
1063#### Produces
1063#### Produces
1064
1064
1065−A list.
1065+A pair of a list and a noun.
1066
1066
1067#### Source
1067#### Source
1068
1068
@@ -1082,20 +1082,20 @@ A list.
1082#### Examples
1082#### Examples
1083
1083
1084```
1084```
1085− > %^ spin (limo ~[4 5 6]) :: trivial example -- does nothing with the state
1085+ > %^ spin (limo ~[4 5 6]) :: Trivial example -- does nothing with the state
1086− |=([n=@ a=@] [n a])
1086+ 0
1087− 0
1087+ |=([n=@ a=@] [n a])
1088− ~[4 5 6]
1088+ [p=~[4 5 6] q=0]
1089
1089
1090− > %^ spin (limo ~[4 5 6]) :: `p` as the index and `q` as the list element
1090+ > %^ spin (limo ~[4 5 6]) :: Form a pair with `p` as the index and `q` as the list element
1091+ 0
1091− |=([n=@ a=@] [`(pair)`[a n] +(a)])
1092+ |=([n=@ a=@] [`(pair)`[a n] +(a)])
1092− 0
1093− ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
1093+ [p=~[[p=0 q=4] [p=1 q=5] [p=2 q=6]] q=3]
1094
1094
1095 > %^ spin (reap 10 0) :: Create 10 random numbers less than `10`
1095 > %^ spin (reap 10 0) :: Create 10 random numbers less than `10`
1096+ ~(. og eny)
1096 |=([n=@ rng=_og] (rads:rng 10))
1097 |=([n=@ rng=_og] (rads:rng 10))
1097− ~(. og eny)
1098+ [p=~[7 8 6 0 1 5 4 7 9 3] q=<4.rvi {a/@uvJ <51.qyl 129.pdd 41.mac 1.ane $141>}>]
1098− ~[5 5 9 4 1 7 9 9 9 6]
1099```
1099```
1100
1100
1101#### Discussion
1101#### Discussion