Hi ! In order to define a multi-tree with an integer at each node, it is possible to write something like this : type int_tree = Content of int * int_tree list...
... "infinity" like "nan" are special floating point values. In your case, infinity is given as because the result exceededs the range of FP numbers. Other...
Christophe TROESTLER
Christophe.Troestler+...
May 1, 2007 11:22 am
7620
Is there anything in one of the standard libraries that implements the decorate-sort-undecorate pattern, as in ruby's sort_by? (sort_by f list should build the...
Fabrice, I don't think this it is possible to recursively define a type and a module in this way (i.e., you want to define TreeSet in terms of int_tree and...
... No. ... Probably one line of code: # let sort_by f l = map snd (sort compare (map (fun x -> f x, x) l));; val sort_by : ('a -> 'b) -> 'a list -> 'a list =...
exp is a type. What's VarExp, why i need to use ( ) to declare type: # let ifs = IfExp NilExp NilExp NilExp;; Syntax error # let i = IfExp(NilExp, NilExp,...
... The mutual recursion is between two types, one of which is in a module. To do this, you just put both definitions in a set of mutually recursive modules so...
Is "_" the entry point of ocaml like C's main ? program will start from "let _"? Thanks. let compile ch = let base_env = V.new_env base_tenv base_venv in let...
... Note that OCaml's Sets are ordered whereas lists are not. ... Use mutually recursive modules: # module rec Tree : sig type t = Content of int * TreeSet.t ...
... Sort of, but not really. OCaml evaluates your code from top to bottom, and it will execute any code not sitting behind a functional abstraction when it...
... Have a look at min_float, max_float, infinity, neg_infinity and nan. Consider how machines represent numbers and why they cannot do computations on huge ...
... The correct expression is let i = IfExp(NilExp, NilExp, Some NilExp, 3);; or, probably, let i = IfExp(NilExp, NilExp, None, 3);; IfExp is a type...
... VarExp is one of the inhabitants of the type exp. A value of this has the label VarExp and a component of type var -- whatever type var is. As for the...
Folks, This doesn't work but how can I work around it? let tab = EasySymtab.symtab () in module P = EasyParser.Make ( struct type t = EasySymtab.symtab_t let...
Hi Christopher ! ... Thanks for the explanations. I'm very sorry : should have told in my question I focus on learning non-O Caml for now. It's enough for me...
Many thanks Jon ! ... That's absolutely perfect ! I begin to grasp the core language but have a lot to work on modules... ... I come from C++ ( and its heavy...
Shalom ! Set functor needs ordered types to make Set modules with ordered compare test. I wonder if it exists a kind of Set library that would rather be based...
How to printf a ref of a bool? like ast and print_ast() here. print a ref of bool let ast = ref false let print_ast() = !ast printf "%B" ast;; Thanks! ...
... Thanks Jon ! You gave me today lot of things to experiment with ! ( Never heard about Mr Pernici programs before and I'm surprised to have missed JCF ds/...
Hi all, Could somebody please help me make sense of OMake / suggest something else or point me at a simple template. I have a simple (but growing) program and...
it works in interactive mode. but got some problems in file driver.ml printf "%B" ! ast error info: File "driver.ml ", line 62, characters 8-12: This...
ast defined in option and print in driver.ml. attached it works in interactive mode. but got some problems in file driver.ml printf "%B" ! ast error info: ...
... ... Sorry, but what is this file : "driver.ml" ? This code correctly compiles : (* Beg of code *) let ast = ref false let _ = Printf.printf "%B" ! ast ...
... I'd suppose that would depend on what you mean by code generation. Could you be a bit more specific as to what you are interested in? William D. Neumann ...