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 a
On Sat, Sep 01, 2007 at 04:59:50AM -0700, Alexteslin wrote:
> 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 amen
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 try
That's just a minor change of plumbing:
import Control.Arrow((***),(&&&),(>>>),app)
import Data.Maybe(catMaybes,maybeToList)
mapPair :: (a -> a -> a) -> [a] -> [a]
mapPair = curry mp where
mp = (((zipWith >>> uncurry) *** -- (inter-elem function
(id &&& tail) >>> -- ,d
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
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:
>
>
Sometimes it is interesting to approach things from a different
perspective. The goofyness below will have been useful if it interests
you in point-free programming. And anyway, I sure had a good time
writing it...
I am composing several common Haskell idioms:
1) When adjacent list elements a
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 rea
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
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 stand
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,
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 exampl
12 matches
Mail list logo