Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Estimating the size of the ocaml community
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-04 (17:24)
From: sejourne_kevin <sejourne_kevin@y...>
Subject: Re: [Caml-list] Estimating the size of the ocaml community
Oliver Bandel a écrit :
> 9.: Pattern matching, that *really* is functional (seems to be necessary that it works
>     like it is done in logical programming languages like Prolog or similar?

Something like this could be fun (just like Prolog):

(*caml way*)
let test = function
     [(1,a);b;(3,c);(4,d)] ->Printf.printf "%d %d %d \n" a c d; b
   | _ -> failwith "Unification Impossible"
(*half-prolog way*)
let test [(1,a);b;(3,c);(4,d)] =  Printf.printf "%d %d %d \n" a c d; b
and test _ = failwith "Unification Impossible"

The second isn't allow, but it isn't a partial match.

With a logic match, Ocaml could be functionnal, imperative, object and 
logic. Just need a dynamic syntax to have the power of Prolog with the 
power of OCaml... cool. The problem with the logic
match (* | "prefix"^str -> *) is that ^ isn't a constructor but a 
function. I think, the logic match can't be determinist. IHMO, Prolog 
can do it just because all data are term(s) as all 'function'.