Brent Yorgey wrote:
On 8/29/07, Alexteslin [EMAIL PROTECTED] wrote:
Hello,
I just came across with this question on the exam and can not think of
implementing it.
Wait, is this an exam for a class you're taking? Or just a problem from
an
exam that you're trying to solve for
On 9/1/07, Alexteslin [EMAIL PROTECTED] wrote:
Hi,
It is the former, but I sat an exam and trying to discuss my exam answers
which will make no difference to what so ever to an exam, as an exam
duration was 1.5 hours. Which means that no matter how much i would like
to
try to amend my
That's great (really, thank you for such a fun example of Arrow
programming), but isn't the (*) on line two of mapPair supposed to be a
point? How would you make a point-less version of mapPair that
actually had the type signature (a-a-a)-[a]-[a]*? (For that matter,
/would/ you?)
Devin
*
Hello,
I just came across with this question on the exam and can not think of
implementing it.
mapPair :: (a - a - a) - [a] - [a]
such that mapPairs f [x1, x2, x3, x4...] = [f x1 x2, f x3 x4,...]
and if the list contains an odd number of elements, the last one is kept
unchanged, for example
Alexteslin wrote:
Hello,
I just came across with this question on the exam and can not think of
implementing it.
mapPair :: (a - a - a) - [a] - [a]
such that mapPairs f [x1, x2, x3, x4...] = [f x1 x2, f x3 x4,...]
and if the list contains an odd number of elements, the last one
Hi Alexteslin,
I just came across with this question on the exam and can not think of
implementing it.
mapPair :: (a - a - a) - [a] - [a]
such that mapPairs f [x1, x2, x3, x4...] = [f x1 x2, f x3 x4,...]
I would implement this using direct recursion. As a starting point,
the standard
Hi
mapPairs :: (a - a - a) - [a] - [a]
mapPairs f [x] = [x]
mapPairs f [] = []
mapPairs f (x:xs) = f x (head xs) : mapPairs f (tail xs)
It looks like it works, but you can get a better version by changing
the last line:
mapPairs f (x:y:zs) = ... - left as an exercise, but no need for head
On 8/29/07, Alexteslin [EMAIL PROTECTED] wrote:
Hello,
I just came across with this question on the exam and can not think of
implementing it.
Wait, is this an exam for a class you're taking? Or just a problem from an
exam that you're trying to solve for fun? If the former, it really
2007/8/30, Neil Mitchell [EMAIL PROTECTED]:
Hi
mapPairs :: (a - a - a) - [a] - [a]
mapPairs f [x] = [x]
mapPairs f [] = []
mapPairs f (x:xs) = f x (head xs) : mapPairs f (tail xs)
It looks like it works, but you can get a better version by changing
the last line:
mapPairs f (x:y:zs)