Skip to content

Instantly share code, notes, and snippets.

@KirinDave
Created November 8, 2008 20:23
Show Gist options
  • Select an option

  • Save KirinDave/23126 to your computer and use it in GitHub Desktop.

Select an option

Save KirinDave/23126 to your computer and use it in GitHub Desktop.
class stack_of_ints =
object (self)
val mutable the_list = ( [] : int list ) (* instance variable *)
method push x = (* push method *)
the_list <- x :: the_list
method pop = (* pop method *)
let result = hd the_list in
the_list <- tl the_list;
result
method peek = (* peek method *)
hd the_list
method size = (* size method *)
length the_list
end;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment