From: Siegfried Gonzi <siegfried.gonzi@stud.uni-graz.at>
To: Brian Hurt <brian.hurt@qlogic.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Easy solution in OCaml?
Date: Sun, 27 Apr 2003 17:01:03 +0200 [thread overview]
Message-ID: <3EABF0AF.10503@stud.uni-graz.at> (raw)
In-Reply-To: <Pine.LNX.4.33.0304261611000.3160-100000@eagle.ancor.com>
>
>
>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
next prev parent reply other threads:[~2003-04-27 16:12 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-25 6:05 Siegfried Gonzi
2003-04-25 8:19 ` sebastien FURIC
2003-04-25 15:46 ` Brian Hurt
2003-04-25 16:34 ` Ville-Pertti Keinonen
2003-04-26 13:45 ` Siegfried Gonzi
2003-04-26 21:51 ` Brian Hurt
2003-04-27 15:01 ` Siegfried Gonzi [this message]
2003-04-28 15:43 ` Brian Hurt
2003-04-29 5:46 ` John Max Skaller
2003-04-27 16:33 ` [Caml-list] Re: IEEE-754 (was: Easy solution in OCaml?) Christophe TROESTLER
2003-04-25 16:59 ` [Caml-list] Easy solution in OCaml? Markus Mottl
2003-04-26 6:25 ` Siegfried Gonzi
2003-04-27 14:13 ` Siegfried Gonzi
2003-04-27 16:54 ` Eray Ozkural
2003-04-28 5:00 ` Siegfried Gonzi
2003-04-28 17:45 ` malc
2003-04-28 18:16 ` Shivkumar Chandrasekaran
[not found] <20030427164326.34082.qmail@web41211.mail.yahoo.com>
2003-04-28 12:05 ` Siegfried Gonzi
2003-04-28 13:54 ` Noel Welsh
2003-04-28 14:22 ` David Brown
2003-04-28 14:38 ` sebastien FURIC
2003-04-28 18:14 ` Eray Ozkural
2003-05-03 14:37 ` John Max Skaller
2003-05-03 16:57 ` Eray Ozkural
2003-04-28 15:27 isaac gouy
2003-04-28 16:38 ` brogoff
2003-04-28 17:13 ` isaac gouy
2003-04-28 17:48 ` Brian Hurt
2003-04-28 17:50 ` brogoff
2003-04-28 18:31 ` Eray Ozkural
2003-04-29 6:46 ` Siegfried Gonzi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EABF0AF.10503@stud.uni-graz.at \
--to=siegfried.gonzi@stud.uni-graz.at \
--cc=brian.hurt@qlogic.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).