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 139 - (view) (download)
Original Path: sml/branches/SMLNJ/src/ml-yacc/lib/stream.sml

1 : monnier 2 (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi
2 :     *
3 :     * $Log$
4 : monnier 139 * Revision 1.1.1.5 1998/09/07 21:10:46 monnier
5 :     * 110.8
6 : monnier 2 *
7 : monnier 139 * Revision 1.1.1.1 1998/04/08 18:40:16 george
8 :     * Version 110.5
9 :     *
10 : monnier 8 * Revision 1.2 1997/08/26 19:18:55 jhr
11 :     * Replaced used of "abstraction" with ":>".
12 :     *
13 : monnier 2 # Revision 1.1.1.1 1997/01/14 01:38:04 george
14 :     # Version 109.24
15 :     #
16 :     * Revision 1.1.1.1 1996/01/31 16:01:43 george
17 :     * Version 109
18 :     *
19 :     *)
20 :    
21 :     (* Stream: a structure implementing a lazy stream. The signature STREAM
22 :     is found in base.sig *)
23 :    
24 :     structure Stream :> STREAM =
25 :     struct
26 :     datatype 'a str = EVAL of 'a * 'a str ref | UNEVAL of (unit->'a)
27 :    
28 :     type 'a stream = 'a str ref
29 :    
30 :     fun get(ref(EVAL t)) = t
31 :     | get(s as ref(UNEVAL f)) =
32 :     let val t = (f(), ref(UNEVAL f)) in s := EVAL t; t end
33 :    
34 :     fun streamify f = ref(UNEVAL f)
35 :     fun cons(a,s) = ref(EVAL(a,s))
36 :    
37 :     end;

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