@@ -108,6 +108,80 @@ parameters first, separated by commas, then we call the function.
108
108
109
109
This takes the 3 numbers, calls "+", which adds them all, then pipes that to out, which prints them.
110
110
111
+ ###Looping
112
+
113
+ for each example
114
+
115
+ ```
116
+ [1,2,3] each
117
+ out
118
+ ```
119
+
120
+ for loop example
121
+
122
+ ```
123
+ [1..5) each
124
+ out
125
+ ```
126
+
127
+ turns into:
128
+
129
+ ```
130
+ for(var i = 1; i < 5; ++i)
131
+ {
132
+ out(i);
133
+ }
134
+ ```
135
+
136
+ also async:
137
+
138
+ ```
139
+ [1,2,3] async.each
140
+ out
141
+ ```
142
+
143
+ turns into:
144
+
145
+ ```
146
+ async.each([1,2,3],function(i,cb){
147
+ out(i);
148
+ return cb();
149
+ });
150
+ ```
151
+
152
+ callbacks trigger at end of scope unless you take control of the callback object using @
153
+
154
+ ```
155
+ [1,2,3] *each
156
+ 'blah' @another_function
157
+ ```
158
+ Using '@' either prefixed or before a function call adds the current callback to the params
159
+
160
+ in this case:
161
+
162
+ ```
163
+ async.each([1,2,3],function(i,cb){
164
+ another_function('blah',cb);
165
+ });
166
+
167
+ ```
168
+
169
+ ###Backcalls
170
+
171
+ ```
172
+ test
173
+ blah
174
+ ```
175
+
176
+ This is equivalent to test(function(){ return blah(); })
177
+
178
+ ```
179
+ test ^
180
+ blah
181
+ ```
182
+
183
+ This is also equivalent to test(function(){ return blah(); })
184
+
111
185
###Packing/Unpacking
112
186
113
187
iox is based around temporary variables being passed down "the stream". Generally these are single values or a list of values.
@@ -149,7 +223,7 @@ Functions in iox take any number of inputs and give any number of outputs.
149
223
Here is a basic function declaration:
150
224
151
225
```
152
- message:
226
+ def message
153
227
"Hello there, ", _
154
228
155
229
# Usage:
@@ -207,22 +281,6 @@ alarm out # wake-up on event (availability of future 'alarm')
207
281
a keypress
208
282
'a pressed!' out
209
283
210
- ###Callbacks/Backcalls
211
-
212
- ```
213
- test
214
- blah
215
- ```
216
-
217
- This is equivalent to test(function(){ return blah(); })
218
-
219
- ```
220
- test ^
221
- blah
222
- ```
223
-
224
- This is also equivalent to test(function(){ return blah(); })
225
-
226
284
###What now?
227
285
228
286
Work in progress :)