[Haskell-cafe] what did I do wrong
Johan Holmquist
holmisen at gmail.com
Mon May 12 06:13:47 UTC 2014
Also, in Haskell all functions take only one parameter. If you want a
function of two (as in the case of center) there are two ways to achieve
that:
Make the argument a tuple or make a function with the first argument
returning another function taking the second. The latter approach is more
common in Haskell.
Your definition of center does that.
foo x y = x *y
is the same as
foo x= \y -> x*y
and
foo = \x -> \y -> x*y
On May 10, 2014 2:05 PM, "Corentin Dupont" <corentin.dupont at gmail.com>
wrote:
> Hi,
> remember that in Haskell argument application is just a space, not using
> parenthesis and comma like in some imperative languages.
> In Java: myFunc (a, b)
> Is equivalent in Haskell to: myfunc a b
> so center ((1,2), (3, 4)) is a function applied to only one arguement (a
> tuple of tuples)
>
>
> On Sat, May 10, 2014 at 2:00 PM, Roelof Wobben <r.wobben at home.nl> wrote:
>
>> Mathijs Kwik schreef op 10-5-2014 13:55:
>>
>> Roelof Wobben <r.wobben at home.nl> writes:
>>>
>>> Hello,
>>>>
>>>> I have to find the center of 2 points as a assigment for a course on
>>>> fpcomplete. This is no homework because I do a self-study.
>>>>
>>>> So I did this:
>>>>
>>>> center (x1,y1) (x2,y2) = ( ((x1+x2)/2),((y1+y2)/2) )
>>>> main = print $ center ((1,2), (3, 4))
>>>>
>>> should be:
>>>
>>> center (x1,y1) (x2,y2) = ( ((x1+x2)/2),((y1+y2)/2) )
>>> main = print $ center (1,2) (3, 4)
>>>
>>>
>>>
>> oke,
>>
>> as I see you changed the main function but I have to make the center
>> function work not change the main function.
>>
>>
>> Roelof
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140512/e488a20b/attachment.html>
More information about the Haskell-Cafe
mailing list