On Sat, Oct 2, 2010 at 10:47 AM, ben kuin <benk...@gmail.com> wrote:
>>
>> # let t x = match x with
>>  a when x<=4 -> true
>>  | _ -> false;;
>>
>
> ok, I had a similar attempt with
>
>    let tt x = function
>    a when x<=4 -> true
>    | _ -> false;;
>
> but that gave me the following (scary  -> 'a -> ) signature
>
>     val tt : int -> 'a -> bool = <fun>
>
> so I stopped
>
> thanks anyway
>

This seems to be a common beginner mistake (hence the reference to the
beginner's list).  You defined tt as a function which takes two
arguments, x and another matched by "function" - which tt ignores the
value of (a when x <= 4).  The pattern-matched value is never used,
therefore it can be any type.

Hope this helps,

Hez

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to