on d760cbf help sign in
bridge/src/nockjs/list.js
40 lines 575 B history raw
1var noun = require('./noun.js'),
2 Cell = noun.Cell,
3 zero = noun.Atom.yes;
5function flop(a) {
6 var b = zero;
8 while ( true ) {
9 if ( zero.equals(a) ) {
10 return b;
11 }
12 else if ( !a.deep ) {
13 throw new Error("Bail");
14 }
15 else {
16 b = new Cell(a.head, b);
17 a = a.tail;
18 }
19 }
22function forEach(n, f) {
23 while ( true ) {
24 if ( zero.equals(n) ) {
25 return;
26 }
27 else if ( !n.deep ) {
28 throw new Error("Bail");
29 }
30 else {
31 f(n.head);
32 n = n.tail;
33 }
34 }
37module.exports = {
38 flop: flop,
39 forEach: forEach,
40};