
20 Mar
2006
20 Mar
'06
1:42 p.m.
Neil Rutland wrote:
stops :: int->int->int
I think that says that the function stops takes two integers and returns an integer.
This is correct (though as someone else pointed out, Haskell types start with a capital letter).
What i'm not entirely sure of is how i'd then write the function itself because i literally want it to have the following form
stops (x,y) = x+y
As "stops" just adds numbers, it is equivalent to the + operator, so you don't have to write a function at all. It doesn't do any harm to write a function, but the simplest way of expressing "stops" is this: stops :: Int -> Int -> Int stops = (+) One of the benefits of a functional language is that you can assign functions as well as data! Pete