From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA06830; Sun, 24 Oct 2004 19:35:54 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA07000 for ; Sun, 24 Oct 2004 19:35:53 +0200 (MET DST) Received: from web53002.mail.yahoo.com (web53002.mail.yahoo.com [206.190.39.192]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id i9OHZqRL022296 for ; Sun, 24 Oct 2004 19:35:53 +0200 Message-ID: <20041024173552.96205.qmail@web53002.mail.yahoo.com> Received: from [136.1.1.101] by web53002.mail.yahoo.com via HTTP; Sun, 24 Oct 2004 10:35:52 PDT Date: Sun, 24 Oct 2004 10:35:52 -0700 (PDT) From: Vasili Galchin Subject: [Caml-list] Patterns in ML vs OCaml ... To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1431047712-1098639352=:96154" X-Miltered: at concorde with ID 417BE7F8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.03; val:01 parms:01 W6:99 val:01 W28:99 W31:99 W28:99 W36:99 parms:01 ocaml:01 ocaml:01 hair:97 hair:97 nil:03 nil:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --0-1431047712-1098639352=:96154 Content-Type: text/plain; charset=us-ascii Hello, I'm sorry this is a very elementary question (but I am pulling my hair out). With a function written in ML: fun filter_list P [] = [] | filter_list P (h :: t) = let val ft = filter_list P t in if P h then (h :: ft) else ft end; OR fun member (e, nil) = false | member (e , (h :: t)) = if (e=h) then true else member (e, t) ; What is the preferred way to write in OCaml using pattern matching on parms?? Regards, Vasili --------------------------------- Do you Yahoo!? vote.yahoo.com - Register online to vote today! --0-1431047712-1098639352=:96154 Content-Type: text/html; charset=us-ascii

Hello,
 
    I'm sorry this is a very elementary question (but I am pulling my hair out). With a function written in ML:
 
fun filter_list P []       = [] |
    filter_list P (h :: t) = let val ft = filter_list P t
                             in if P h then (h :: ft)
                                else ft
                             end;
 
OR
 
fun member (e, nil) = false |
    member (e , (h :: t)) = if (e=h) then true
                                     else member (e, t) ;

What is the preferred way to write in OCaml using pattern matching on parms??
 
Regards, Vasili


Do you Yahoo!?
vote.yahoo.com - Register online to vote today! --0-1431047712-1098639352=:96154-- ------------------- 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