Results 1 to 2 of 2

Thread: help in SML
      
   

  1. #1
    morgoth is offline Private
    Join Date
    Dec 2006
    Posts
    2

    Default 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

  2. #2
    Bethers's Avatar
    Bethers is offline Major General & Forum Moderator
    Join Date
    Feb 2006
    Posts
    5,232

    Default 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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49