Annotation of researchv10no/cmd/sml/doc/examples/missionaries/buffers.sml, revision 1.1

1.1     ! root        1: (* depth-first state buffer -- implements a stack *)
        !             2: 
        !             3: structure DF : BUFFER =
        !             4: struct
        !             5:   type 'a buffer = 'a list
        !             6:   exception EMPTY
        !             7:   val empty = []
        !             8:   fun get [] = raise EMPTY
        !             9:     | get(x::l) = (x,l)
        !            10:   fun put(x,l) = x::l
        !            11: end
        !            12: 
        !            13: 
        !            14: (* breadth-first state buffer -- implements an applicative queue *)
        !            15: 
        !            16: structure BF : BUFFER =
        !            17: struct
        !            18:   type 'a buffer = 'a list * 'a list
        !            19:   exception EMPTY
        !            20:   val empty = ([],[])
        !            21:   fun get([],[]) = raise EMPTY
        !            22:     | get(a::r,l) = (a,(r,l))
        !            23:     | get([],l) = get(rev l,[])
        !            24:   fun put(x,(m,l)) = (m,x::l)
        !            25: end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.