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