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 TAA05928; Wed, 22 Aug 2001 19:52:30 +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 TAA05817 for ; Wed, 22 Aug 2001 19:52:28 +0200 (MET DST) Received: from wsnyc.fame.com (pixnj254.fame.com [192.88.60.254]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f7MHqO910864 for ; Wed, 22 Aug 2001 19:52:26 +0200 (MET DST) Received: from CONSULTING2000P (dhcp-ny-245.fame.com [192.88.66.245]) by wsnyc.fame.com (8.9.3/8.9.3) with ESMTP id NAA08027 for ; Wed, 22 Aug 2001 13:52:21 -0400 (EDT) From: "Collin Monahan" To: Subject: [Caml-list] newbie questions Date: Wed, 22 Aug 2001 13:58:01 -0400 Organization: FAME Information Services, Inc. Message-ID: <000501c12b33$fc06b8f0$f54258c0@CONSULTING2000P> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0006_01C12B12.74F518F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C12B12.74F518F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, I'm new to the list, and to Caml and to ML in general. I'm having stupid problems one after the other trying to learn this, and was wondering if anyone had some extra time to field questions, without my bothering the whole list. Thank you, Collin Monahan ------=_NextPart_000_0006_01C12B12.74F518F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

 

Hi,

 

I’m new to the list, and to Caml and to ML in general. I’m having stupid problems one after the = other trying to learn this, and was wondering if anyone had some extra time to = field questions, without my bothering the whole = list.

 

Thank you,

Collin = Monahan

 

------=_NextPart_000_0006_01C12B12.74F518F0-- ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr 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 BAA13264; Tue, 11 Dec 2001 01:25:35 +0100 (MET) 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 BAA13108 for ; Tue, 11 Dec 2001 01:25:34 +0100 (MET) Received: from smtp01.eresmas.com ([62.81.160.176]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fBB0PXL15716 for ; Tue, 11 Dec 2001 01:25:34 +0100 (MET) Received: from holmes.localdomain ([62.174.10.213]) by smtp01.eresmas.com (Netscape Messaging Server 4.15) with ESMTP id GO5L6J00.K6A for ; Tue, 11 Dec 2001 01:25:31 +0100 Received: (from jao@localhost) by holmes.localdomain (8.11.6/8.11.6) id fBB0PmG04388; Tue, 11 Dec 2001 01:25:48 +0100 (CET) (envelope-from jaortega@acm.org) X-Authentication-Warning: holmes.localdomain: jao set sender to jaortega@acm.org using -f To: caml-list@inria.fr Subject: [Caml-list] newbie questions X-Attribution: jao X-URL: From: "Jose A. Ortega Ruiz" Organization: Using FreeBSD 4.4 Date: 11 Dec 2001 01:25:48 +0100 Message-ID: <86y9kak3g3.fsf@holmes.localdomain> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk hi, i'm learning OCaml (coming from a professional C/C++, Java background, with a little bit of elisp and scheme (read SICP)), and own a copy of Cousineau & Mauny's book (O'Reilly's Objective Caml is on the way). i would really appreciate your advice on the following topics: - C&M uses Caml (light?): is it worth reading while learning OCaml? do you know of any comparison of the two languages i should read if using C&M? - my ultimate goal is using OCaml for real, useful projects: any idea about specially needed/useful applications in OCaml i could help on? - any suggestion/recommendation/roadmap for my journey learning OCaml? as i said before, your comments would be highly appreciated. thanks, -- jao ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr 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 DAA14230; Tue, 11 Dec 2001 03:34:42 +0100 (MET) 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 DAA14271 for ; Tue, 11 Dec 2001 03:34:42 +0100 (MET) Received: from smtp.nwlink.com (smtp.nwlink.com [209.20.130.57]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBB2YeH24311 for ; Tue, 11 Dec 2001 03:34:40 +0100 (MET) Received: from ip178.usw22.rb1.bel.nwlink.com (ip178.usw22.rb1.bel.nwlink.com [207.202.195.178]) by smtp.nwlink.com (8.9.3/8.9.1) with SMTP id SAA13422 for ; Mon, 10 Dec 2001 18:33:47 -0800 (PST) Received: (qmail 16234 invoked by uid 500); 11 Dec 2001 02:32:26 -0000 Date: Mon, 10 Dec 2001 18:32:26 -0800 From: Mike Leary To: "Jose A. Ortega Ruiz" Cc: caml-list@inria.fr Subject: Re: [Caml-list] newbie questions Message-ID: <20011210183226.A16211@ip178.usw22.rb1.bel.nwlink.com> References: <86y9kak3g3.fsf@holmes.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <86y9kak3g3.fsf@holmes.localdomain>; from jaortega@acm.org on Tue, Dec 11, 2001 at 01:25:48AM +0100 Organization: is a poor substitute for less junk Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk a number of people liked the notes for this course: http://www.cs.caltech.edu/cs134/cs134b/ On Tue, Dec 11, 2001 at 01:25:48AM +0100, Jose A. Ortega Ruiz wrote: > > hi, > > i'm learning OCaml (coming from a professional C/C++, Java background, > with a little bit of elisp and scheme (read SICP)), and own a copy of > Cousineau & Mauny's book (O'Reilly's Objective Caml is on the way). i > would really appreciate your advice on the following topics: > > - C&M uses Caml (light?): is it worth reading while learning OCaml? do > you know of any comparison of the two languages i should read if > using C&M? > > - my ultimate goal is using OCaml for real, useful projects: any idea > about specially needed/useful applications in OCaml i could help on? > > - any suggestion/recommendation/roadmap for my journey learning OCaml? > > as i said before, your comments would be highly appreciated. > > thanks, > > -- > jao > ------------------- > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr -- "You mean, I'm the bad guy?" --Bill Foster, aka D-FENS ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr 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 LAA19059; Tue, 11 Dec 2001 11:23:32 +0100 (MET) 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 LAA18783 for ; Tue, 11 Dec 2001 11:23:31 +0100 (MET) Received: from dpt-info.u-strasbg.fr (dpt-info.u-strasbg.fr [130.79.44.193]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fBBANVX29836 for ; Tue, 11 Dec 2001 11:23:31 +0100 (MET) Received: (from luther@localhost) by dpt-info.u-strasbg.fr (8.9.3/8.9.3) id LAA29959; Tue, 11 Dec 2001 11:23:56 +0100 Date: Tue, 11 Dec 2001 11:23:56 +0100 From: Sven To: "Jose A. Ortega Ruiz" Cc: caml-list@inria.fr Subject: Re: [Caml-list] newbie questions Message-ID: <20011211112356.B29853@dpt-info.u-strasbg.fr> References: <86y9kak3g3.fsf@holmes.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <86y9kak3g3.fsf@holmes.localdomain>; from jaortega@acm.org on Tue, Dec 11, 2001 at 01:25:48AM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Dec 11, 2001 at 01:25:48AM +0100, Jose A. Ortega Ruiz wrote: > > hi, > > i'm learning OCaml (coming from a professional C/C++, Java background, > with a little bit of elisp and scheme (read SICP)), and own a copy of > Cousineau & Mauny's book (O'Reilly's Objective Caml is on the way). i > would really appreciate your advice on the following topics: > > - C&M uses Caml (light?): is it worth reading while learning OCaml? do > you know of any comparison of the two languages i should read if > using C&M? Ocaml is based on caml light, there are some syntactic changes, and some additional stuff (like the object system and the modules). If you can make abstraction of this synctactic changes, most of the C&M book should apply as well to ocaml. Since it shows many functional programming tricks, i gues syou could as well use it with other functional languages as sml or even lisp based ones :))) > - my ultimate goal is using OCaml for real, useful projects: any idea > about specially needed/useful applications in OCaml i could help on? There surelly are many things you can help on, myself, i am planning a small work in a landscape building sysytem, a bit like terraform, but in ocaml. I don't really have that many time for it though, write to me if you are interrested. Friendly, Sven Luther ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr 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 JAA21023; Sat, 29 Mar 2003 09:49:34 +0100 (MET) 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 JAA32439 for ; Sat, 29 Mar 2003 09:49:33 +0100 (MET) Received: from omta02.mta.everyone.net (sitemail3.everyone.net [216.200.145.37]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2T8nV513544 for ; Sat, 29 Mar 2003 09:49:32 +0100 (MET) Received: from sitemail.everyone.net (dsnat [216.200.145.62]) by omta02.mta.everyone.net (Postfix) with ESMTP id 2E3AD1C3FEA; Sat, 29 Mar 2003 00:48:40 -0800 (PST) Received: by sitemail.everyone.net (Postfix, from userid 99) id BAF874C99; Sat, 29 Mar 2003 00:48:39 -0800 (PST) Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Mailer: MIME-tools 5.41 (Entity 5.404) Date: Sat, 29 Mar 2003 00:48:39 -0800 (PST) From: "Dr.Dr.Ruediger M.Flaig" To: caml-list@inria.fr Subject: [Caml-list] newbie questions Reply-To: flaig@hallucinogene.sanctacaris.net X-Originating-Ip: [129.206.124.135] Message-Id: <20030329084839.BAF874C99@sitemail.everyone.net> X-Spam: no; 0.00; newbie:01 neophyte:01 recursion:01 haskell:01 erlang:01 slower:01 'g':01 iterative:01 cha:99 inference:01 algol:01 gcc:01 marcus:01 heidelberg:99 compilers:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Good morning to all you bedouins out there :-) , as I am a neophyte to CAML, forgive me if my questions have been asked (and answered) a hundred times before... 1.: Is there any means of doing list-type pattern matching (style "| h::t -> ...") for recursion on strings? OK., I have realized that not having a decent string type is one of the reason why programs in Haskell or Erlang are much slower than in CAML, and resorted to a "roll-your-own" for dealing with this: let ht x = (String.sub x 1 ((String.length x)-1)), String.make 1 (compl x.[0]);; because I think that let compl = function 'g' -> 'c' | 'c' -> 'g' | 'a' -> 't' | 't' -> 'a' | _ -> ' ';; let rec complement = function "" -> "" | dna -> let h, t = ht dna in (complement h) ^ t;; is much smarter than the iterative version let compl = function 'g' -> 'c' | 'c' -> 'g' | 'a' -> 't' | 't' -> 'a' | _ -> ' ';; let complement dna = let cdna = ref "" in for i = 0 to String.length( dna )-1 do let cha = String.get dna i in cdna := (String.make 1 (compl cha)) ^ !cdna done; !cdna;; (Yes! Confess guilty! Learned Pascal in 1986...) but -- and this is my point -- there should certainly be some more elegant way of dealing with this than the horrible "ht" definition, shouldn't it? 2.: A question on language design: why do recursive functions have to be marked explicitly as such? My personal feeling is that this rather spoils the nifty inference system... from Algol to Java, procedural compilers require explicit type definitions but are able to work out for themselves if a routine is recursive, and Haskell also has both type inference and implicit recursion, so this should not be too difficult. Or has there anything escaped my attention? 3.: I have followed the thread about speed with considerable interest... my personal impression is that on a PPC processor, OCaml code is sometimes even faster than C code! (Does not hold true for dft, I admit.) This may have to do with the queer gcc supplied by Apple, which does not appear to make good use of the PPC's wealth of registers... hence I would like to have some output in legible form but the -S option does not seem to work properly. Does anybody know about this? Yours sincerely, Ruediger Dr. Dr. Ruediger Marcus Flaig Institute for Immunology University of Heidelberg Im Neuenheimer Feld 305 D-69120 Heidelberg Tel. +49-172-7652946 Fax +49-4075110-17171 _____________________________________________________________ Free eMail .... the way it should be.... http://www.hablas.com _____________________________________________________________ Select your own custom email address for FREE! Get you@yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag ------------------- 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 KAA32334; Sat, 29 Mar 2003 10:15:50 +0100 (MET) 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 KAA00670 for ; Sat, 29 Mar 2003 10:15:49 +0100 (MET) Received: from kraid.nerim.net (smtp-102.nerim.net [62.4.16.102]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h2T9FmX13384 for ; Sat, 29 Mar 2003 10:15:48 +0100 (MET) Received: from hector.lesours (lesours.starynkevitch.net [80.65.224.217]) by kraid.nerim.net (Postfix) with ESMTP id F1AA94102B; Sat, 29 Mar 2003 10:15:47 +0100 (CET) Received: from basile by hector.lesours with local (Exim 3.36 #1 (Debian)) id 18zCRH-00085x-00; Sat, 29 Mar 2003 10:15:47 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <16005.25667.709552.511315@hector.lesours> Date: Sat, 29 Mar 2003 10:15:47 +0100 To: , Cc: caml-list@inria.fr Subject: [Caml-list] newbie questions In-Reply-To: <20030329084839.BAF874C99@sitemail.everyone.net> References: <20030329084839.BAF874C99@sitemail.everyone.net> X-Mailer: VM 7.13 under Emacs 21.2.2 From: Basile STARYNKEVITCH X-Spam: no; 0.00; basile:01 caml-list:01 newbie:01 neophyte:01 recursion:01 recursions:01 faiencerie:01 92340:01 reine:01 nerim:01 htmlman:01 tunes:01 bindings:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>>>> "Ruediger" == Dr Ruediger M Flaig writes: Ruediger> Good morning to all you bedouins out there :-) , as I am Ruediger> a neophyte to CAML, forgive me if my questions have been Ruediger> asked (and answered) a hundred times before... You might have checked in the mailing list archive before asking... Ruediger> 1.: Is there any means of doing list-type pattern Ruediger> matching (style "| h::t -> ...") for recursion on Ruediger> strings? [...] unfortunately no. You cannot have pattern matching on strings. But the Str module might help (it provides regular expressions). See also recent postings on this issue: http://caml.inria.fr/archives/200303/msg00289.html http://caml.inria.fr/archives/200303/msg00399.html Ruediger> 2.: A question on language design: why do recursive Ruediger> functions have to be marked explicitly as such? [...] Any (syntactically non-recursive) *expression* can appear on the right hand side of let bindings, but this is not true for let rec bindings which are restriced (syntactically) to functions and constant constructors see http://caml.inria.fr/ocaml/htmlman/manual015.html for more (Historical note; many other languages require syntactic marking of recursions: Scheme, Fortran90, PL1, ...) -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet aliases: basiletunesorg = bstarynknerimnet 8, rue de la Faïencerie, 92340 Bourg La Reine, France ------------------- 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 MAA01297; Sat, 29 Mar 2003 12:05:08 +0100 (MET) 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 MAA02617 for ; Sat, 29 Mar 2003 12:05:03 +0100 (MET) Received: from mwinf0202.wanadoo.fr (smtp5.wanadoo.fr [193.252.22.29]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2TB51517630 for ; Sat, 29 Mar 2003 12:05:02 +0100 (MET) Received: from ptit-gallu.home.net (AVelizy-112-1-5-121.abo.wanadoo.fr [81.48.248.121]) by mwinf0202.wanadoo.fr (Postfix) with ESMTP id C68B2A400110; Sat, 29 Mar 2003 12:04:59 +0100 (CET) Received: from gallu.home.net ([192.168.0.12]) by ptit-gallu.home.net with esmtp (Exim 3.35 #1 (Debian)) id 18zE8t-0008Q5-00; Sat, 29 Mar 2003 12:04:55 +0100 Received: from gildor by gallu.home.net with local (Exim 3.36 #1 (Debian)) id 18zE8w-0005bQ-00; Sat, 29 Mar 2003 12:04:58 +0100 Date: Sat, 29 Mar 2003 12:04:58 +0100 To: flaig@hallucinogene.sanctacaris.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] newbie questions Message-ID: <20030329110458.GA21457@gallu.home.net> References: <20030329084839.BAF874C99@sitemail.everyone.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030329084839.BAF874C99@sitemail.everyone.net> User-Agent: Mutt/1.5.3i From: Sylvain LE GALL X-Spam: no; 0.00; gall:01 le-gall:01 caml-list:01 newbie:01 neophyte:01 recursion:01 haskell:01 erlang:01 slower:01 'g':01 bug:01 biological:99 ocaml:01 caml:01 token:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, Mar 29, 2003 at 12:48:39AM -0800, Dr.Dr.Ruediger M.Flaig wrote: > Good morning to all you bedouins out there :-) , > > as I am a neophyte to CAML, forgive me if my questions have been asked (and answered) a hundred times before... > > > 1.: Is there any means of doing list-type pattern matching (style "| h::t -> ...") for recursion on strings? OK., I have realized that not having a decent string type is one of the reason why programs in Haskell or Erlang are much slower than in CAML, and resorted to a "roll-your-own" for dealing with this: > As i see your code, i think you maybe miss something in caml : typing help you to program ! If i have understood, you work on DNA code. In my mind DNA base type should be : in dna.ml type dna = A | C | G | T ( and arn = A | C | G | U ) type gene = dna list let ht x = match x with A -> T | T -> A | G -> C | C -> G (* give you the ht transform of you DNA list *) let complement lst = List.iter ht lst If you want more pattern matching : let ht_exp lst = match lst with A :: A :: A :: tl_lst -> T :: ( ht_exp tl_lst ) | A :: x :: A :: tl_lst -> T :: (ht x) :: (ht_exp tl_lst) ...usw Iy you want to convert your string to dna type : in parser_dna.mly %token A %token T %token C %token G %token EOF %start main %type main %% main: A main { Dna.A :: $2 } |C main { Dna.C :: $2 } |T main { Dna.T :: $2 } |G main { Dna.G :: $2 } |EOF { [] } ; in lexer_dna.mll { open Parser_dna } rule token = parse 'a' { A } | 't' { T } | 'c' { C } | 'g' { G } | eof { EOF } and then you can transform a string with let lexbuf = Lexing.from_string "acgtacgt" in let result = Parser_dna.main Lexer_dna.token lexbuf and result will contain [ A ; C ; G ; T; A; C; G; T ] I am not sure that is what you want. But when you program in Ocaml, i think it is better to use it as ocaml ( not trying to use techniques you should have used in other languages ). I hope it will help you. I have just typed the code as it comes, it is surely full of bug. Kind regard Sylvain LE GALL ps : i am surely not a genetic expert... there is maybe a lot of biological non sense. ------------------- 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 LAA22559; Sun, 30 Mar 2003 11:52:35 +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 LAA22588 for ; Sun, 30 Mar 2003 11:52:34 +0200 (MET DST) Received: from inria.fr (planar.net0.nerim.net [213.41.168.102]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2U9qX501857 for ; Sun, 30 Mar 2003 11:52:34 +0200 (MET DST) Date: Sun, 30 Mar 2003 11:53:00 +0200 Subject: Re: [Caml-list] newbie questions Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Damien Doligez To: caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: <20030329084839.BAF874C99@sitemail.everyone.net> Message-Id: <648DC56F-6295-11D7-B6B4-0003930FCE12@inria.fr> X-Mailer: Apple Mail (2.551) X-Spam: no; 0.00; damien:01 caml-list:01 newbie:01 'g':01 inference:01 algol:01 implicitly:01 haskell:01 recursion:01 gcc:01 ocamlopt:01 inefficient:01 -bit:01 compilers:01 rec:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Saturday, March 29, 2003, at 09:48 AM, Dr.Dr.Ruediger M.Flaig wrote: > let ht x = (String.sub x 1 ((String.length x)-1)), String.make 1 > (compl x.[0]);; Any program that uses this function is going to be horribly inefficient. You should do something like this instead: let string_map f s = let result = String.copy s in for i = 0 to (String.length s - 1) do result.[i] <- f s.[i]; done; result ;; let compl = function 'g' -> 'c' | 'c' -> 'g' | 'a' -> 't' | 't' -> 'a' | _ -> ' ';; let complement s = string_map compl s;; This should be able to handle the complete human genome (a 3 gigabyte string) without problems (on a 64-bit machine with enough memory). > 2.: A question on language design: why do recursive functions have to > be marked explicitly as such? My personal feeling is that this rather > spoils the nifty inference system... from Algol to Java, procedural > compilers require explicit type definitions but are able to work out > for themselves if a routine is recursive, All these language have different syntax for defining functions/procedures and for defining values, and make functions implicitly recursive. In effect, you are "marking" your functions as recursive by defining them. You can get the same effect in O'Caml by always using "let rec" for your functions. > and Haskell also has both type inference and implicit recursion, so > this should not be too difficult. Or has there anything escaped my > attention? Haskell is a lazy language, and has no problem with arbitrary recursive values. In a strict language like O'Caml, we cannot make all values recursive by default. > hence I would like to have some output in legible form but the -S > option does not seem to work properly. Does anybody know about this? Do you mean gcc -S or ocamlopt -S ? They both work on my MacOS X. -- Damien ------------------- 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 QAA27248; Sun, 30 Mar 2003 16:23:46 +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 QAA26966 for ; Sun, 30 Mar 2003 16:23:45 +0200 (MET DST) Received: from batch12.uni-muenster.de (BATCH12.UNI-MUENSTER.DE [128.176.188.110]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h2UENdX26397 for ; Sun, 30 Mar 2003 16:23:41 +0200 (MET DST) Received: from zivlnx01.uni-muenster.de (ZIVLNX01.UNI-MUENSTER.DE [128.176.188.24]) by batch12.uni-muenster.de (Postfix) with ESMTP id 6886510C3; Sun, 30 Mar 2003 16:23:32 +0200 (MES) Received: from localhost (localhost.uni-muenster.de [127.0.0.1]) by zivlnx01.uni-muenster.de (Postfix with Virus Detection) with ESMTP id 65BA3312C9; Sun, 30 Mar 2003 16:23:32 +0200 (CEST) Received: from uni-muenster.de (WI-STRUPPI.UNI-MUENSTER.DE [128.176.159.176]) by zivlnx01.uni-muenster.de (Postfix with Virus Detection) with ESMTP id DA292312C6; Sun, 30 Mar 2003 16:23:26 +0200 (CEST) Date: Sun, 30 Mar 2003 16:23:39 +0200 Subject: Re: [Caml-list] newbie questions Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: caml-list@inria.fr To: flaig@hallucinogene.sanctacaris.net From: Wolfgang Lux In-Reply-To: <20030329084839.BAF874C99@sitemail.everyone.net> Message-Id: <33A4A5A2-62BB-11D7-938F-0003937628DA@uni-muenster.de> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS 0.3.12pre7 X-Spam: no; 0.00; wlux:01 uni-muenster:01 caml-list:01 newbie:01 recursion:01 haskell:01 erlang:01 slower:01 'g':01 iterative:01 cha:99 recursions:01 implemented:01 arrays:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ruediger M.Flaig wrote: > 1.: Is there any means of doing list-type pattern matching (style "| > h::t -> ...") for recursion on strings? OK., I have realized that not > having a decent string type is one of the reason why programs in > Haskell or Erlang are much slower than in CAML, and resorted to a > "roll-your-own" for dealing with this: > > let ht x = (String.sub x 1 ((String.length x)-1)), String.make 1 > (compl x.[0]);; > > because I think that > > let compl = function 'g' -> 'c' | 'c' -> 'g' | 'a' -> 't' | 't' -> 'a' > | _ -> ' ';; > let rec complement = function > "" -> "" > | dna -> let h, t = ht dna in (complement h) ^ t;; > > is much smarter than the iterative version > > let compl = function 'g' -> 'c' | 'c' -> 'g' | 'a' -> 't' | 't' -> 'a' > | _ -> ' ';; > let complement dna = > let cdna = ref "" in > for i = 0 to String.length( dna )-1 do > let cha = String.get dna i in > cdna := (String.make 1 (compl cha)) ^ !cdna > done; > !cdna;; > > (Yes! Confess guilty! Learned Pascal in 1986...) > > but -- and this is my point -- there should certainly be some more > elegant way of dealing with this than the horrible "ht" definition, > shouldn't it? Actually, in many cases you would not want to implement such recursions yourself. Many recursion patterns can implemented by using the standard higher order functions unit, map, fold, etc. For instance, your complement function should be as simple as let complement dna = String.map compl dna To my surprise, the String module doesn't provide a map function (it does implement iter, though). If you were using an algebraic data type type Base = A | C | G | T you could make use of arrays and the implement complement using Array.map. Wolfgang ------------------- 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