SCM Repository
[diderot] Diff of /trunk/src/compiler/fields/shape.sml
Diff of /trunk/src/compiler/fields/shape.sml
Parent Directory
|
Revision Log
|
Patch
21 |
|
|
22 |
val map : ('a -> 'b) * ('c -> 'd) -> ('a,'c) shape -> ('b,'d) shape |
val map : ('a -> 'b) * ('c -> 'd) -> ('a,'c) shape -> ('b,'d) shape |
23 |
|
|
24 |
|
(* right-to-left traversal of the tree *) |
25 |
val foldr : ('a * 'b -> 'b) -> 'b -> ('c,'a) shape -> 'b |
val foldr : ('a * 'b -> 'b) -> 'b -> ('c,'a) shape -> 'b |
26 |
|
|
27 |
|
val appPreOrder : ('nd -> unit) * ('lf -> unit) -> ('nd, 'lf) shape -> unit |
28 |
|
|
29 |
end = struct |
end = struct |
30 |
|
|
31 |
datatype ('nd, 'lf) shape |
datatype ('nd, 'lf) shape |
55 |
fold (t, init) |
fold (t, init) |
56 |
end |
end |
57 |
|
|
58 |
|
fun appPreOrder (ndFn, lfFn) = let |
59 |
|
fun app (ND(attr, kids)) = (ndFn attr; List.app app kids) |
60 |
|
| app (LF attr) = lfFn attr |
61 |
|
in |
62 |
|
app |
63 |
|
end |
64 |
|
|
65 |
end |
end |
|
Legend:
Removed from v.352 |
|
changed lines |
|
Added in v.353 |
|
|