[Haskell-cafe] Haskell vs OCaml
Branimir Maksimovic
bmaxa at hotmail.com
Sun Dec 25 06:06:25 EST 2005
>From: Matt Collins <mattcol at gmail.com>
>To: "Branimir Maksimovic" <bmaxa at hotmail.com>
>CC: Haskell-Cafe at haskell.org
>Subject: Re: [Haskell-cafe] Haskell vs OCaml
>Date: Sun, 25 Dec 2005 21:42:35 +1100
>
>Perhaps something like
>
>for :: Int -> Int -> (Int -> IO ()) -> IO ()
>for begin end f = sequence_ [ f i | i <- [begin..end] ]
>
>*Main> for 1 10 print
>1
>2
>3
>4
>5
>6
>7
>8
>9
>10
>
Great! what are constrains on [begin..end] could they be some type
which supports (+) , but not Int. I need this cause perhaps there is
possibility to impleemnt STL like algo's in Haskell and that would
be even better then C++, cause Haskell has more powerfull
parametric polimorfism and C++ badly needs lambda's.
That's why STL is somewhat ugly, but lib tried to employ functional
style programming over sequences and is not bad, though in C++
one has to make lot of auxiliary classes because of lack of lambda's.
If I can make Iterator generic class and specialize for different
containers that would be it.
Last question is: Does creation of list of functions humpers performance?
Greetings, Bane.
>
>On 25/12/2005, at 9:35 PM, Branimir Maksimovic wrote:
>
>>
>>
>>
>>>From: Lennart Augustsson <lennart at augustsson.net>
>>>To: Branimir Maksimovic <bmaxa at hotmail.com>
>>>CC: daniel.carrera at zmsl.com, Haskell-Cafe at haskell.org
>>>Subject: Re: [Haskell-cafe] Haskell vs OCaml
>>>Date: Sun, 25 Dec 2005 10:25:44 +0100
>>>
>>>Branimir Maksimovic wrote:
>>>>I've found that Haskell is pretty good in implementing recursive
>>>>algorithms.
>>>>Problem cames when one want's to implement non recursive algorithm
>>>>by terms of recursion as Haskell does not support loops.
>>>>Perhaps if we can get loops, situation will improve, but then that
>>>>wouldn't be functional style.
>>>
>>>Could you give an example of a loop you find awkward in Haskell?
>>
>>Well I want simple loop for(int i =0;i<10;++i)doSomething(i);
>>in haskell that would be
>>for begin end f | begin /= end = do {f begin ; for (begin+1) end f}
>> | otherwise = return ()
>>
>>>I've often found that you can just define a control construct
>>>in Haskell when needed (e.g., some kind of loop).
>>
>>I don't know how to do that.
>>
>>Greetings, Bane.
>>
>>_________________________________________________________________
>>Express yourself instantly with MSN Messenger! Download today it's FREE!
>>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>>
>>_______________________________________________
>>Haskell-Cafe mailing list
>>Haskell-Cafe at haskell.org
>>http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
More information about the Haskell-Cafe
mailing list