help in SML

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • morgoth
    Private

    • Dec 2006
    • 2

    help in SML

    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
  • Bethers
    Major General & Forum Moderator

    • Feb 2006
    • 5224

    #2
    Re: help in SML

    IF you want help with this - you need to find the appropriate room to post it in - no business is allowed in the lounge.
    Beth
    A Child's Palace - Pinata Palace - Moxie Enterprises

    SEO and Marketing Tools
    SEO - The Basics

    Comment

    Working...
    X