equal
deleted
inserted
replaced
81 exception Empty |
81 exception Empty |
82 |
82 |
83 fun getItem (Seq s) = force s |
83 fun getItem (Seq s) = force s |
84 fun make f = Seq (delay f) |
84 fun make f = Seq (delay f) |
85 |
85 |
86 fun null s = is_some (getItem s) |
86 fun null s = isSome (getItem s) |
87 |
87 |
88 local |
88 local |
89 fun F n NONE = n |
89 fun F n NONE = n |
90 | F n (SOME(_,s)) = F (n+1) (getItem s) |
90 | F n (SOME(_,s)) = F (n+1) (getItem s) |
91 in |
91 in |
395 | SOME(x,xs) => SOME(x,make (fn () => copy xs)) |
395 | SOME(x,xs) => SOME(x,make (fn () => copy xs)) |
396 in |
396 in |
397 make (fn () => copy (f x)) |
397 make (fn () => copy (f x)) |
398 end |
398 end |
399 |
399 |
400 fun EVERY fs = foldr THEN (fs, succeed) |
400 fun EVERY fs = Library.foldr THEN (fs, succeed) |
401 fun FIRST fs = foldr ORELSE (fs, fail) |
401 fun FIRST fs = Library.foldr ORELSE (fs, fail) |
402 |
402 |
403 fun TRY f x = |
403 fun TRY f x = |
404 make (fn () => |
404 make (fn () => |
405 case getItem (f x) of |
405 case getItem (f x) of |
406 NONE => SOME(x,Seq (value NONE)) |
406 NONE => SOME(x,Seq (value NONE)) |