i am taking a sml class and while studying the class notes i came across the following piece of code:
datatype 'a stream = STREAM of unit ->( 'a * 'a stream )
fun consstreams (x: 'a ,y: 'a stream ) = STREAM(fn()=>(x,y))
fun head (STREAM s) = #1 (s())
fun tail (STREAM s) = #2 (s())
fun force (STREAM s) = ( #1 (s()), #2 (s()) )
fun prefix (n:int) ((STREAM S): 'a stream) = []: 'a list
now i understand that sml is not the prefered language for streams, but this is intended as a demonstration of the differences between sml and scheme. however, i have no idea what #1 and #2 stand for, i have an idea of what they might do, but i would like someone who could explain this thing to me...
many thanks
datatype 'a stream = STREAM of unit ->( 'a * 'a stream )
fun consstreams (x: 'a ,y: 'a stream ) = STREAM(fn()=>(x,y))
fun head (STREAM s) = #1 (s())
fun tail (STREAM s) = #2 (s())
fun force (STREAM s) = ( #1 (s()), #2 (s()) )
fun prefix (n:int) ((STREAM S): 'a stream) = []: 'a list
now i understand that sml is not the prefered language for streams, but this is intended as a demonstration of the differences between sml and scheme. however, i have no idea what #1 and #2 stand for, i have an idea of what they might do, but i would like someone who could explain this thing to me...
many thanks
Comment