No subject


Wed Apr 10 17:18:51 CEST 2013


=A0 =A0 snd $ fn&#39; (zip [x] [a]) =3D fn [a]</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">I can see ways of doin=
g this by altering fn, or by repeating some of fn in the definition of fn&#=
39;, or (because in this case I know that if fn xs =3D x, fn is returning t=
he first x in xs and not any others), by doing something nasty like:</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">=A0 fn&#39; xs =3D xs =
!! fromMaybe 0 (findIndex (\(_,a) -&gt; a =3D=3D fn (snd $ unzip xs)) xs )<=
br></div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">But it seems to me lik=
e there should be prettier solutions to this (that=A0<i>do not</i>=A0involv=
e changing the definition of fn). After all, this doesn&#39;t seem like a r=
are pattern.</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">Anyone know if in fact=
 there&#39;s a better way to go about it?</div></div>

--f46d042de425749bab04dcc4c06b--



More information about the Beginners mailing list