No subject


Wed Apr 10 17:18:51 CEST 2013


    snd $ fn' (zip [x] [a]) = fn [a]

I can see ways of doing this by altering fn, or by repeating some of
fn in the definition of fn', or (because in this case I know that if
fn xs = x, fn is returning the first x in xs and not any others), by
doing something nasty like:

  fn' xs = xs !! fromMaybe 0 (findIndex (\(_,a) -> a == fn (snd $
unzip xs)) xs )

But it seems to me like there should be prettier solutions to this
(that do not involve changing the definition of fn). After all, this
doesn't seem like a rare pattern.

Anyone know if in fact there's a better way to go about it?



More information about the Beginners mailing list