Find out value of max_int without using the the constant max_int ... Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software [Non-text...
... You can try min_int - 1;; Otherwise you can use shift functions (lsl, lsr, ...) or an arithmetic approach: increase an int until its value decreases....
... let rec find_max x = if x + 1 < x then x else find_max (x + 1) ;; find_max 17 ;; (* have a drink *) Cheers. -- Stefano Zacchiroli -- Master in Computer...
... Or on a binary computer ... let rec find_max x = if x * 2 > x then find_max (x * 2) else x * 2 - 1;; print_string (string_of_int (find_max 1) ^ "\n");; ...
... Why? To me this sounds suspiciously like a homework assignment. max_int is in pervasives, you don't even need to preface with Sys.max_int or Int.max_int...
Brian Hurt
brian.hurt@...
Sep 2, 2003 2:10 pm
1305
Warning: I'm very new to OCAML. I may need some patience :) Example: type ratio = {num: int; denum: int};; type number = Int of int | Float of float | Error;; ...
I'm just wondering how you can guarantee that certain imperative effects occur, like adding a name into a symbol table hash. I'm writing a compiler whose...
... Hey, records have little to do with variants. And I think that it is quite personal of you to state "The reason that "Int" is constructor and "num" is not...
... Well, the : mean "have the type", for example: - in {num: int; denum: int} the num field have the type int - in « val foo : bar » the function foo have...
Hello, I am a beginners, and I ask for some help When you use Lex, you can use the directive BEGIN for a analyse (ex: expr* [ BEGIN(EXPR); return athing;] ...
I find that I need a mutable, variable-sized Array type. Is there one available, either in the standard library or an external library for OCaml? Rich. -- ...
... [...] ... You have been mixing the tokens and the rules, it seems. Read carefully, and reproduce, the ocamllex/ocamlyacc complete example in the manual...
... Ok, so, i can't, like with lex, 'send' a token to the parser(ocamlyacc) and continue my parsing with ocamllex like a wrote with : (t)* {ATHING; expr...
... If mot, mot2, mot3 are just generic "WORDS", you can't distinguish them at the parsing level (they are lexemes of the same token). I'll suppose that...
I'm just wondering how you can guarantee that certain imperative effects occur in an ocamlyacc grammar, like adding a name into a symbol table hash. I'm...
# let fn () = let static_var = ref 0 in let r = !static_var in static_var := !static_var + 1; r;; val fn : unit -> int = <fun> # fn ();; - : int = 0 # fn ();; ...
... let fn = let static_var = ref 0 in fun () -> let r = !static_var in incr static_var; r ;; val fn : unit -> int = <fun> # fn ();; - : int = 0 # fn ();; - :...
... It is. You just need to put the static_var before the actual arguments of fn (otherwise static_var is part of the closure) # let fn = let static_var = ref...
Boris Yakobowski
Boris.Yakobowski@...
Sep 5, 2003 10:07 am
1321
let make_counter init = let counter = ref init in ((fun () -> incr counter), (fun () -> !counter)) let (step, get) = make_counter 0 Using this way, you can...
Martin Jambon
m.jambon@...
Sep 5, 2003 11:10 am
1322
The ocaml interpreter is able to get the string representation of arbitrary types. (You can define any type you like, the execute a function that returns that...
A different problem relating to the same debugging session as my previous message. :) How can I use the ocaml debugger to debug a program that uses ncurses? I...
I am wasting my time now and I just don't see it: Task: I want to parse a datafile containing lines like this: Course|Description|Designer|Email|Phone ...
Johann Spies
jspies@...
Sep 6, 2003 2:30 pm
1325
... A lot of information that are available at compile time (such as type) are lost at execution time. The ocaml toplevel is (at the same time) the compiler...
... Thanks, I'll look into it. ... Don't worry, you won't be inconvenienced, because you are replying to the list and not to me personally. If you were writing...
Without looking too deeply into your problem: ... val hanteer_eposse : string list -> (string * string * string * string) list = <fun> ... kurshuskode and...
... Just an idea: maybe if you write with english-like identifiers, the ocamlers with mother-tongues different that yours would understand your purposes...