Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/releases/release-110.37/src/ml-yacc/lib/stream.sml
ViewVC logotype

View of /sml/releases/release-110.37/src/ml-yacc/lib/stream.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 994 - (download) (annotate)
Fri Nov 23 02:37:10 2001 UTC (18 years, 10 months ago)
File size: 511 byte(s)
This commit was manufactured by cvs2svn to create tag
'release-110.37'.
(* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi *)

(* Stream: a structure implementing a lazy stream.  The signature STREAM
   is found in base.sig *)

structure Stream :> STREAM =
struct
   datatype 'a str = EVAL of 'a * 'a str ref | UNEVAL of (unit->'a)

   type 'a stream = 'a str ref

   fun get(ref(EVAL t)) = t
     | get(s as ref(UNEVAL f)) = 
	    let val t = (f(), ref(UNEVAL f)) in s := EVAL t; t end

   fun streamify f = ref(UNEVAL f)
   fun cons(a,s) = ref(EVAL(a,s))

end;

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0