src/Pure/General/seq.ML
changeset 15574 b1d1b5bfc464
parent 15570 8d8c70b41bab
child 16002 e0557c452138
equal deleted inserted replaced
15573:cf53c2dcf440 15574:b1d1b5bfc464
    95   (case pull xq of
    95   (case pull xq of
    96     NONE => []
    96     NONE => []
    97   | SOME (x, xq') => x :: list_of xq');
    97   | SOME (x, xq') => x :: list_of xq');
    98 
    98 
    99 (*conversion from list to sequence*)
    99 (*conversion from list to sequence*)
   100 fun of_list xs = Library.foldr cons (xs, empty);
   100 fun of_list xs = foldr cons empty xs;
   101 
   101 
   102 
   102 
   103 (*map the function f over the sequence, making a new sequence*)
   103 (*map the function f over the sequence, making a new sequence*)
   104 fun map f xq =
   104 fun map f xq =
   105   make (fn () =>
   105   make (fn () =>
   201   | some => make (fn () => some));
   201   | some => make (fn () => some));
   202 
   202 
   203 fun op APPEND (f, g) x =
   203 fun op APPEND (f, g) x =
   204   append (f x, make (fn () => pull (g x)));
   204   append (f x, make (fn () => pull (g x)));
   205 
   205 
   206 fun EVERY fs = Library.foldr THEN (fs, succeed);
   206 fun EVERY fs = foldr THEN succeed fs;
   207 fun FIRST fs = Library.foldr ORELSE (fs, fail);
   207 fun FIRST fs = foldr ORELSE fail fs;
   208 
   208 
   209 fun TRY f = ORELSE (f, succeed);
   209 fun TRY f = ORELSE (f, succeed);
   210 
   210 
   211 fun REPEAT f =
   211 fun REPEAT f =
   212   let
   212   let