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 SAA19265; Sun, 27 Apr 2003 18:12:51 +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 SAA19087 for ; Sun, 27 Apr 2003 18:12:49 +0200 (MET DST) Received: from teutates.kfunigraz.ac.at (TEUTATES.kfunigraz.ac.at [143.50.129.26]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h3RGCnT13701 for ; Sun, 27 Apr 2003 18:12:49 +0200 (MET DST) Received: from localhost (localhost.localdomain [127.0.0.1]) by teutates.kfunigraz.ac.at (Postfix) with ESMTP id 83E993D222A; Sun, 27 Apr 2003 18:12:48 +0200 (CEST) Received: from teutates.kfunigraz.ac.at ([127.0.0.1]) by localhost (teutates.kfunigraz.ac.at [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 02418-08; Sun, 27 Apr 2003 18:12:47 +0200 (CEST) Received: from stud.uni-graz.at (IGAM08AV.kfunigraz.ac.at [143.50.39.35]) by teutates.kfunigraz.ac.at (Postfix) with ESMTP id AD9B93D2221; Sun, 27 Apr 2003 18:12:46 +0200 (CEST) Message-ID: <3EABF0AF.10503@stud.uni-graz.at> Date: Sun, 27 Apr 2003 17:01:03 +0200 From: Siegfried Gonzi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: Brian Hurt Cc: Ocaml Mailing List Subject: Re: [Caml-list] Easy solution in OCaml? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at stud.uni-graz.at X-Spam: no; 0.00; siegfried:01 gonzi:01 stud:99 caml-list:01 generic:01 char:01 implicitly:01 104.:99 103.:99 bug:01 string-:01 haskell:01 realm:01 bigloo:01 erg:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > >Brian Hurt wrote: > > >If you don't know what you just pulled out of a list, how can you do >anything with it? About all you can do with it is to move it around. >Take it out of one data structure and put it into another. Or pass it to >some other function. Which you can quite happily do with Ocaml- take a >look at List.map or Array.of_list in the standard libraries for examples. > >But once you want to do something more with the elements than just move >them around, you need to know what they are- what type they are. So let's >say I'm expecting that I'm dealing with an int list list (your first >example there). I could easily convert this to a float list list by >doing: > >let conv lst = List.map (fun l -> List.map (float_of_int) l) lst > >With some suitable generic handling, instead of calling List.map, I just >call map, so when I hit an array of ints instead of a list of ints, I call >Array.map and not List.map. It could be done, it'd be of limited use but >it could be done. But what am I supposed to do with the string "hi guy"? >Should it treat the string as a list of char, implicitly convert it to a >list of int, and then convert the list of int to a list of float, >returning [104.; 105.; 32.; 103.; 117.; 121.]? What sensible thing can >you do here? > >This is what I meant about a bug in your program or not thinking the >design through. If there is a reason you're putting a string into that >list, it means something. Decide what it means, and at each point you >handle elements from that list, decide what to do if you see a string- >even if it's just "ignore it and go on", think about it and decide. > Before I commence I have to say: there exists actually only 2 functional languages which deserve to be used by industry: this is OCaml and Haskell. Okay, in the Scheme realm only Bigloo (and mybe PLT Scheme) stands for "ready for industry". But I have to say that Clean's elegant syntax is way, way, way above OCaml ones. It is often very comfortable to use this sort of bad hacking, because in science when you develop new functions or tries to solve problems you often do not know in advance what you want and not. For example: function1 has as return: erg1 = (list (list 2 3 4)) function2 expects output from function1 and function2 uses this output as follows: (list-ref erg1 0) But now I decide for reason of its own that erg1 should include just one more information: erg1 = (list1 (list 2 3 4) (list (vector 2 3 4) "nice day")) function2 now is not affected because it always uses the first element of the list, but it dramatically shortens your development time, because you do not have to cope with other structures or tuples in erg1 as you would do lets say in Clean. And you do not have to change all your other dependencies. This was the reason to ask in my first post of the topic are there any guys out there who successfully use OCaml for data evaluation or lets call it statistic (which means reading files, coping with array and lists and that sort of). Maybe the aforementioned bad feature of Scheme/Lisp/Python... makes them that usefull for coping with "dynamic" data. This also leads to the question: is development time really reduced in (strict typed) functional programming, or is it only reduced when you compare quicksort in Haskell and the verbose version in C. Regards, S. Gonzi ------------------- 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