src/HOL/Import/lazy_seq.ML
changeset 21395 f34ac19659ae
parent 20594 b80c4a5cd018
child 28670 f8bd813b41f9
equal deleted inserted replaced
21394:9f20604d2b5e 21395:f34ac19659ae
   451 	       | SOME (x', _) => SOME(x',Seq (value NONE)))
   451 	       | SOME (x', _) => SOME(x',Seq (value NONE)))
   452 
   452 
   453 (*partial function as procedure*)
   453 (*partial function as procedure*)
   454 fun try f x =
   454 fun try f x =
   455     make (fn () =>
   455     make (fn () =>
   456 	     case Library.try f x of
   456 	     case Basics.try f x of
   457 		 SOME y => SOME(y,Seq (value NONE))
   457 		 SOME y => SOME(y,Seq (value NONE))
   458 	       | NONE => NONE)
   458 	       | NONE => NONE)
   459 
   459 
   460 (*functional to print a sequence, up to "count" elements;
   460 (*functional to print a sequence, up to "count" elements;
   461   the function prelem should print the element number and also the element*)
   461   the function prelem should print the element number and also the element*)
   526     if n <= 0
   526     if n <= 0
   527     then ([], xq)
   527     then ([], xq)
   528     else
   528     else
   529 	case getItem xq of
   529 	case getItem xq of
   530 	    NONE => ([], xq)
   530 	    NONE => ([], xq)
   531 	  | SOME (x, xq') => apfst (Library.cons x) (chop (n - 1, xq'))
   531 	  | SOME (x, xq') => apfst (Basics.cons x) (chop (n - 1, xq'))
   532 
   532 
   533 fun foldl f e s =
   533 fun foldl f e s =
   534     let
   534     let
   535 	fun F k NONE = k e
   535 	fun F k NONE = k e
   536 	  | F k (SOME(x,s)) = F (fn y => k (f(x,y))) (getItem s)
   536 	  | F k (SOME(x,s)) = F (fn y => k (f(x,y))) (getItem s)