Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] function
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Issac Trotts <ijtrotts@u...>
Subject: Re: [Caml-list] function
On Mon, Dec 02, 2002 at 04:55:06PM +0100, altavillasalvatore@libero.it wrote:
> Hi all,
> I would want to know if a function exists that allows me to make this:
> 
> ["123";"45";"678"]  ->  [1;2;3;4;5;6;7;8;].

let f l = 
  let ret = ref [] in
  String.iter 
    (fun c -> ret := ((int_of_char c) - (int_of_char '0')) :: !ret) 
    (List.fold_left (^) "" l);
  List.rev !ret;;
  
f ["123";"45";"678"];;

Cheers,
Issac Trotts

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners