I have a list with words. I need to print them and number them. The only way I found to do it is by using reference variables: let i = ref 1 in List.iter (fun...
13676
Sebastien Mondet
sebmondet
Nov 20, 2012 1:27 pm
'iteri39; does what you want: List.iteri ;; - : (int -> 'a -> unit) -> 'a list -> unit = <fun> ... [Non-text portions of this message have been removed]...
13677
Esther Baruk
surdinal09
Nov 20, 2012 1:28 pm
Hi, The latest version of OCaml includes new stdlib functions like List.iteri or List.mapi which integrate a counter in their arguments. List.iteri has the...
13678
rixed@...
rixed
Nov 20, 2012 2:45 pm
If your ocaml stdlib's do not have List.iteri you can find it on batteries : http://ocaml-batteries-team.github.com/batteries-included/hdoc/BatList.html...
13679
darooha
Nov 21, 2012 12:01 pm
Here's how I would do it: let print_list words = List.fold_left (fun i w -> Printf.printf "%d: %s\n" i w; (i+1)) 1 words List.fold_left is pretty important, so...
13680
Esther Baruk
surdinal09
Nov 21, 2012 12:44 pm
Yes, but in this case, the type returned by List.fold_left is int and the print_word function should definitely have unit return type. Esther Baruk ... ...
13681
Minhyuk Kwon
mugerc
Nov 21, 2012 12:58 pm
Hello I think, your problem is not good when using functional. You can make it functional. But, use reference! It's ok! We are not on the pure functional...
13682
Francois Berenger
f_berenger
Nov 22, 2012 12:40 am
... For your info, this line: i := !i+1 is incr i in the standard library (increment an integer reference). ... List.iteri (fun i w -> Printf.printf "%d: %s\n"...
13683
Florent Monnier
fmonnier@...
Nov 22, 2012 2:06 pm
... In recent version of OCaml there's List.iteri, otherwise you can use List.fold_left instead: let _ = List.fold_left (fun i w -> print_endline...
13684
Denis Setecordas
denis7cordas
Nov 26, 2012 10:55 pm
Hi, I have just installed OCAML 4.00 on my computer (Windows 7 / 64 bits) with, as required by Inria documentation, a cygwin environment. All seems working...
13685
Chantal Keller
chantal.keller@...
Nov 27, 2012 8:38 am
Hi Denis, I never used cygwin, but you may try to install OCaml and ocamlgraph using GODI <http://godi.camlcity.org/godi/index.html>. Hope this helps, Chantal....
13686
Francois Berenger
f_berenger
Nov 27, 2012 8:43 am
... Or, on a Linux computer (Ubuntu or Debian) with ocamlbrew and OPAM....
13687
Chantal Keller
chantal.keller@...
Nov 27, 2012 8:49 am
... Or using the package manager if you are root... Chantal....
13688
Gabriel Scherer
ga_sche
Nov 27, 2012 9:07 am
No, you certainly don't need a "full cygwin install"; however, being unfamiliar with Windows or Cygwin I wouldn't know which subset is necessary. Have you...
13689
George
siberianowl
Nov 27, 2012 8:19 pm
In my parser I need to create unique labels and insert them into various places in the syntax tree. So in the parser.mly I wrote: %{ let auto_label_counter =...
13690
Jeff Massung
ocamlferret
Nov 27, 2012 8:36 pm
Does anyone have a trivial example of a Makefile for an Ocaml project that does the following: ocamllex a file ocamlyacc a file compile all the ml files using...
13691
George
siberianowl
Nov 27, 2012 8:48 pm
... Well, the trick here is to create a real list of dependencies. Here is my makefile. It may be not very trivial, but it works fine. Just define your source...
13692
Gabriel Scherer
ga_sche
Nov 27, 2012 9:13 pm
Side remark: If you're doing the work of creating a project template, you may as well do the work upfront of using Menhir instead of ocamlyacc, as it is a...
13693
Philippe Veber
philippeveber
Nov 27, 2012 10:10 pm
Hi Jeff I know it doesn't answer your question directly but why not use oasis for this? You wouldn't have to bother at all... Cheers, ph. PS BTW, I'd recommend...
13694
Philippe Veber
philippeveber
Nov 27, 2012 10:14 pm
Hi Georges, [make_label] is not a function and is indeed evaluated only once at the beginning of your program, hence what you observe. You need [make_label] to...
13695
Eric Cooper
ecc@...
Nov 27, 2012 10:14 pm
... You've defined make_label as a simple value, not a function. Try defining and invoking it as "make_label ()" instead. -- Eric Cooper e c c @ c...
13696
Francois Berenger
f_berenger
Nov 28, 2012 12:08 am
... Indeed, using the package manager should be the preferred way for beginners. Debian and Ubuntu have a lot of ocaml packages. For example this interesting...
13697
Shalini Gangwar
shelly_2904
Nov 29, 2012 9:31 am
Hello, I am totally new to the OCAML programming language . I want to know how to connect to a database in ocaml when user is asked about the username and...
13698
Sergei Steshenko
sergstesh
Nov 29, 2012 10:08 am
I am new too. You are asking essentially two questions: 1) interactive I/O; 2) database interface. Regarding the latter:...
13699
George
siberianowl
Nov 30, 2012 5:19 pm
Trying to make a helpful explanation of parsing errors. In my parser.mly I now have: %{ open Lexing;; open Printf;; let report_error message error_starts_at = ...
13700
Shalini Gangwar
shelly_2904
Dec 1, 2012 11:16 am
How to make your own help command in ocaml and display the options with it?? [Non-text portions of this message have been removed]...
13701
Philippe Veber
philippeveber
Dec 1, 2012 11:28 am
Hi Shalini, There are plenty of libraries for that, you can have a look at the Arg module in the standard library [1], the getopt library by Alain Frisch [2] ...
13702
Ashish Agarwal
ashish_a1975
Dec 2, 2012 12:54 am
... The relevant module in Core is Command: https://ocaml.janestreet.com/ocaml-core/108.07.01/doc/core/Command.html [Non-text portions of this message have...
13703
Shalini Gangwar
shelly_2904
Dec 10, 2012 9:24 pm
while executing "make" command , got error: Unbound Module - Postgresql Tried again installing postgresql-ocaml library error occurs: E: Failure("Command...
13704
Philippe Veber
philippeveber
Dec 11, 2012 7:52 am
Hi Shalini, I'm not sure what you are trying to do, installing pgocaml ? Try describing more thoroughly your problem. If that's an install problem, maybe you...