comparison functional.rhope @ 88:f69987c58fa8

Merge
author Mike Pavone <pavone@retrodev.com>
date Fri, 30 Jul 2010 19:52:54 -0400
parents 6d41b71f1b77
children e73a93fb5de1
comparison
equal deleted inserted replaced
87:3c4325e6298f 88:f69987c58fa8
19 }{ 19 }{
20 out <- start 20 out <- start
21 } 21 }
22 } 22 }
23 23
24 _Map[list,worker,cur:out]
25 {
26 val <- [list]Index[cur]
27 nlist <- [list]Set[cur, [worker]Call[val, cur]]
28
29 [nlist]Next[cur]
30 {
31 out <- _Map[nlist, worker, ~]
32 }{
33 out <- Val[nlist]
34 }
35 }
36
37 Map[list,worker:out]
38 {
39 [list]First
40 {
41 out <- _Map[list,worker,~]
42 }{
43 out <- list
44 }
45 }
46
47 _Find[list,pred,cur:loc,not found]
48 {
49 val <- [list]Index[cur]
50 If[[pred]Call[val]]
51 {
52 loc <- cur
53 }{
54 ,not found <- [list]Next[cur]
55 { loc,not found <- _Find[list,pred,~] }
56 }
57 }
58
59 Find[list,pred:loc,not found]
60 {
61 ,not found <- [list]First
62 {
63 loc <- _Find[list,pred,~]
64 }
65 }
66
67 _Filter[list,pred,cur,dest:out]
68 {
69 val <- [list]Index[cur]
70 If[[pred]Call[val,cur]]
71 {
72 ndest <- [dest]Append[val]
73 }{
74 ndest <- dest
75 }
76 [list]Next[cur]
77 {
78 out <- _Filter[list,pred,~,ndest]
79 }{
80 out <- Val[ndest]
81 }
82 }
83
84 Filter[list,pred:out]
85 {
86 [list]First
87 {
88 out <- _Filter[list,pred,~, List[]]
89 }{
90 out <- list
91 }
92 }
93