Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] '_a out of nowhere? (list.reverse)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] '_a out of nowhere? (list.reverse)
         Objective Caml version 3.07+2

# let cons x y = x::y
   and flip f x = f y x;;
Unbound value y
# let cons x y = x::y
   and flip f x y = f y x;;
val cons : 'a -> 'a list -> 'a list = <fun>
val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c = <fun>
# let reverse = fun l -> List.fold_left (flip cons) [] l;;
val reverse : 'a list -> 'a list = <fun>
# reverse [1;2;3];;
- : int list = [3; 2; 1]
# reverse ['a';'b';'c'];;
- : char list = ['c'; 'b'; 'a']


It's a faq,

<http://caml.inria.fr/FAQ/FAQ_EXPERT- 
eng.html#variables_de_types_faibles>

Daniel

-------------------
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