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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/ml-yacc/lib/stream.sml
ViewVC logotype

Annotation of /sml/trunk/src/ml-yacc/lib/stream.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 652 - (view) (download)

1 : monnier 249 (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi
2 :     *
3 :     * $Log$
4 : blume 652 * Revision 1.3 2000/06/06 02:14:54 blume
5 :     * merging changes from devel branch; new boot files
6 :     *
7 :     * Revision 1.1.1.10.2.1 2000/06/02 08:11:06 blume
8 :     * added several appendices to CM manual;
9 :     * merged recent changes to main trunk into devel branch
10 :     *
11 : monnier 651 * Revision 1.2 2000/06/01 18:33:44 monnier
12 :     * bring revisions from the vendor branch to the trunk
13 :     *
14 : monnier 249 * Revision 1.1.1.10 1999/04/17 18:56:10 monnier
15 :     * version 110.16
16 :     *
17 :     * Revision 1.2 1997/08/26 19:18:55 jhr
18 :     * Replaced used of "abstraction" with ":>".
19 :     *
20 :     # Revision 1.1.1.1 1997/01/14 01:38:04 george
21 :     # Version 109.24
22 :     #
23 :     * Revision 1.1.1.1 1996/01/31 16:01:43 george
24 :     * Version 109
25 :     *
26 :     *)
27 :    
28 :     (* Stream: a structure implementing a lazy stream. The signature STREAM
29 :     is found in base.sig *)
30 :    
31 :     structure Stream :> STREAM =
32 :     struct
33 :     datatype 'a str = EVAL of 'a * 'a str ref | UNEVAL of (unit->'a)
34 :    
35 :     type 'a stream = 'a str ref
36 :    
37 :     fun get(ref(EVAL t)) = t
38 :     | get(s as ref(UNEVAL f)) =
39 :     let val t = (f(), ref(UNEVAL f)) in s := EVAL t; t end
40 :    
41 :     fun streamify f = ref(UNEVAL f)
42 :     fun cons(a,s) = ref(EVAL(a,s))
43 :    
44 :     end;

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