When I see the definition of the build-in type of stack:
(* Ocaml-2.04 / stdlib / stack.ml *) Type 'at = {mutable c:' a list} (* t means what's here *) to make the exception empty () = {c = []} clear s = Sc & lt; - [] push xs = sc & lt; - x :: sc let pop s = match with HD :: TL - & gt; S.c & lt; - tl; HD | [] - & gt; Leave the lifting length = list.Lambul s.c let's do this s = List.iter f s.c What type of type is in "T" type? Thanks for explaining I thought it should only be the primitive type in type definition
After defining "text" itemprop = "text"> in ocaml c coding is used to define The type of code explained by the module, t means the stack type. Since the file name is assumed with the missed ocaml module, stack.t for t Use it to view the following in the high-level ocaml (known as REPL) and see the output.
# emtpy_stack = stack.create () ;; Val empty_stack: '_a Stack.t = & lt; Abstr & gt; Here is a variable of empty_stack type Stack.t an empty pile though. In addition, it says that if you want to define a task that takes stack as a logic; Here is a way to define with type annotation, # stack_func: (int) Stack.t = s;; Val stack_dummy: int stack.t - & gt; Int Stack.t = & lt; Funny & gt;
No comments:
Post a Comment