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 AAA02959; Wed, 15 Oct 2003 00:47:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA20788 for ; Wed, 15 Oct 2003 00:47:26 +0200 (MET DST) Received: from hotmail.com (law10-oe45.law10.hotmail.com [64.4.14.17]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9EMlP128409 for ; Wed, 15 Oct 2003 00:47:25 +0200 (MET DST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 14 Oct 2003 15:47:24 -0700 Received: from 141.149.237.84 by law10-oe45.law10.hotmail.com with DAV; Tue, 14 Oct 2003 22:47:23 +0000 X-Originating-IP: [141.149.237.84] X-Originating-Email: [bhavik_gandhi@hotmail.com] Reply-To: From: "Bhavik Gandhi \(hotmail\)" To: Subject: [Caml-list] Facing syntax error. Date: Tue, 14 Oct 2003 18:49:11 -0800 Message-ID: <000401c392c6$e9c5a550$0900a8c0@maverick> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0005_01C39283.DBA3EBF0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-OriginalArrivalTime: 14 Oct 2003 22:47:24.0077 (UTC) FILETIME=[226465D0:01C392A5] X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ocaml:01 ocaml:01 rec:01 rec:01 syntax:02 syntax:02 match:02 match:02 novice:03 novice:03 tail:03 tail:03 let:04 let:04 arial:95 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C39283.DBA3EBF0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hi friends, I am a novice to the OCAML language. I am trying to write a small program and I am facing with a syntax error, any help will be appreciated let rec undup lst = try match lst with |[]->[] |h::tail -> match tail with |[]->[] |h::xt -> if (h=List.hd xt) then h::undup xt else raise(Failure "ERROR-Your list does not contain duplicates");; Error: line 6, characters 67-69 Syntax error. Bhavik Gandhi ------=_NextPart_000_0005_01C39283.DBA3EBF0 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

Hi friends,

 

I am a novice to the OCAML language. I am trying to = write a small program and I am facing with a syntax error, any help will be = appreciated

 

let rec undup lst =3D try match lst = with

  = |[]->[]

  |h::tail -> match tail = with

  = |[]->[]

  |h::xt -> if (h=3DList.hd xt) then h::undup = xt

  else raise(Failure "ERROR-Your list does not contain = duplicates");;

 

Error: line 6, characters = 67-69

Syntax = error.

 

 

Bhavik Gandhi

------=_NextPart_000_0005_01C39283.DBA3EBF0-- ------------------- 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 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 BAA25490; Wed, 15 Oct 2003 01:38:11 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA19237 for ; Wed, 15 Oct 2003 01:38:09 +0200 (MET DST) Received: from mz1.forethought.net (mzpi3.forethought.net [216.241.36.12]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9ENc6100974 for ; Wed, 15 Oct 2003 01:38:08 +0200 (MET DST) Received: from [216.241.35.41] (helo=swordfish) by mz1.forethought.net with esmtp (Exim 4.14) id 1A9Yjs-00026i-Qx for caml-list@pauillac.inria.fr; Tue, 14 Oct 2003 17:38:04 -0600 Received: from matt by swordfish with local (Exim 3.35 #1 (Debian)) id 1A9Yk0-00074W-00 for ; Tue, 14 Oct 2003 17:38:12 -0600 Date: Tue, 14 Oct 2003 17:38:11 -0600 From: Matt Gushee To: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Facing syntax error. Message-ID: <20031014233811.GA26799@swordfish> Reply-To: Matt Gushee Mail-Followup-To: caml-list@pauillac.inria.fr References: <000401c392c6$e9c5a550$0900a8c0@maverick> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000401c392c6$e9c5a550$0900a8c0@maverick> User-Agent: Mutt/1.3.27i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; gushee:01 gushee:01 caml-list:01 endline:01 englewood:01 manure:01 mgushee:01 havenrock:01 havenrock:01 ignores:01 --lao:01 merel:01 ocaml:01 handler:01 rec:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Oct 14, 2003 at 06:49:11PM -0800, Bhavik Gandhi (hotmail) wrote: > > I am a novice to the OCAML language. I am trying to write a small > program and I am facing with a syntax error, any help will be > appreciated > > let rec undup lst = try match lst with > |[]->[] > |h::tail -> match tail with > |[]->[] > |h::xt -> if (h=List.hd xt) then h::undup xt > else raise(Failure "ERROR-Your list does not contain duplicates");; > > Error: line 6, characters 67-69 > Syntax error. Right, because you have 'try' without 'with'. The syntax is try with -> | -> (* 2nd & further patterns are optional *) You could make the above example work by adding a 'with' clause at the end, e.g. with Failure -> print_endline "Exception handled."; [] (* exception handler must return same type as main operation *) But that would actually be a little pointless in this case, since as far as I can tell the only possible exception is the Failure raised by your code. So without knowing your objectives in more detail, I would say the most sensible approach would be to simply delete 'try' from this function, and perhaps have a complete try-with block in some other function that is calling this one. -- Matt Gushee When a nation follows the Way, Englewood, Colorado, USA Horses bear manure through mgushee@havenrock.com its fields; http://www.havenrock.com/ When a nation ignores the Way, Horses bear soldiers through its streets. --Lao Tzu (Peter Merel, trans.) ------------------- 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 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 JAA23478; Wed, 15 Oct 2003 09:51:13 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA09539 for ; Wed, 15 Oct 2003 09:51:12 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9F7pB123805 for ; Wed, 15 Oct 2003 09:51:11 +0200 (MET DST) Received: from fistandantilus.takhisis.org (dhcp139.dmi.ens.fr [129.199.97.139]) by nef.ens.fr (8.12.10/1.01.28121999) with ESMTP id h9F7p8cp050405 for ; Wed, 15 Oct 2003 09:51:08 +0200 (CEST) Received: by fistandantilus.takhisis.org (Postfix, from userid 3148) id 09CDE274042; Wed, 15 Oct 2003 09:51:08 +0200 (CEST) Date: Wed, 15 Oct 2003 09:51:08 +0200 From: Stefano Zacchiroli To: caml-list@inria.fr Subject: Re: [Caml-list] Facing syntax error. Message-ID: <20031015075107.GD11292@fistandantilus.takhisis.org> Mail-Followup-To: caml-list@inria.fr References: <000401c392c6$e9c5a550$0900a8c0@maverick> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000401c392c6$e9c5a550$0900a8c0@maverick> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; bononia:01 caml-list:01 beginners:01 beginners:01 bononia:01 ocaml:01 ocaml:01 groups:01 syntax:02 syntax:02 bologna:03 wrote:03 zacchiroli:03 zacchiroli:03 oct:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Oct 14, 2003 at 06:49:11PM -0800, Bhavik Gandhi (hotmail) wrote: > I am a novice to the OCAML language. I am trying to write a small > program and I am facing with a syntax error, any help will be > appreciated Please use the beginners list for this kind of questions: http://groups.yahoo.com/group/ocaml_beginners Cheers. -- Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} - http://www.bononia.it/zack/ " I know you believe you understood what you think I said, but I am not sure you realize that what you heard is not what I meant! " -- G.Romney ------------------- 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