Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /archive/0.93/doc/examples/missionaries/buffers.sml
ViewVC logotype

View of /archive/0.93/doc/examples/missionaries/buffers.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4958 - (download) (annotate)
Wed Apr 10 01:33:29 2019 UTC (3 months ago) by dbm
File size: 530 byte(s)
adding 0.93 src and doc to archive
(* depth-first state buffer -- implements a stack *)

structure DF : BUFFER =
struct
  type 'a buffer = 'a list
  exception EMPTY
  val empty = []
  fun get [] = raise EMPTY
    | get(x::l) = (x,l)
  fun put(x,l) = x::l
end


(* breadth-first state buffer -- implements an applicative queue *)

structure BF : BUFFER =
struct
  type 'a buffer = 'a list * 'a list
  exception EMPTY
  val empty = ([],[])
  fun get([],[]) = raise EMPTY
    | get(a::r,l) = (a,(r,l))
    | get([],l) = get(rev l,[])
  fun put(x,(m,l)) = (m,x::l)
end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0