SCM Repository
Annotation of /sml/branches/SMLNJ/src/ml-yacc/lib/stream.sml
Parent Directory
|
Revision Log
Revision 8 - (view) (download)
1 : | monnier | 2 | (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi |
2 : | * | ||
3 : | * $Log$ | ||
4 : | monnier | 8 | * Revision 1.1.1.2 1998/01/18 01:00:08 monnier |
5 : | * *** empty log message *** | ||
6 : | monnier | 2 | * |
7 : | monnier | 8 | * Revision 1.2 1997/08/26 19:18:55 jhr |
8 : | * Replaced used of "abstraction" with ":>". | ||
9 : | * | ||
10 : | monnier | 2 | # Revision 1.1.1.1 1997/01/14 01:38:04 george |
11 : | # Version 109.24 | ||
12 : | # | ||
13 : | * Revision 1.1.1.1 1996/01/31 16:01:43 george | ||
14 : | * Version 109 | ||
15 : | * | ||
16 : | *) | ||
17 : | |||
18 : | (* Stream: a structure implementing a lazy stream. The signature STREAM | ||
19 : | is found in base.sig *) | ||
20 : | |||
21 : | structure Stream :> STREAM = | ||
22 : | struct | ||
23 : | datatype 'a str = EVAL of 'a * 'a str ref | UNEVAL of (unit->'a) | ||
24 : | |||
25 : | type 'a stream = 'a str ref | ||
26 : | |||
27 : | fun get(ref(EVAL t)) = t | ||
28 : | | get(s as ref(UNEVAL f)) = | ||
29 : | let val t = (f(), ref(UNEVAL f)) in s := EVAL t; t end | ||
30 : | |||
31 : | fun streamify f = ref(UNEVAL f) | ||
32 : | fun cons(a,s) = ref(EVAL(a,s)) | ||
33 : | |||
34 : | end; |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |