
Awesome, thanks! Sometime around Fri, Jun 20, 2003 at 09:47:54PM -0400, mike castleman said:
On Fri, Jun 20, 2003 at 06:23:42PM -0700, Brett Kelly wrote:
now, i know i've got a syntax problem, because i'm pretty sure my logic is correct (or at least MOSTLY correct).
Try:
pyindex :: Eq a => a -> [a] -> Maybe Int pyindex c l = pyindex' 0 l where pyindex' _ [] = Nothing pyindex' n (x:xs) = if (x == c) then Just n else pyindex' (n+1) xs
then, in ghci: Pyindex> pyindex 'e' "brett" Just 2 Pyindex> pyindex 'm' "brett" Nothing Pyindex> pyindex 't' "brett" Just 3
hope this helps. mike
-- mike castleman / m at mlcastle dot net / http://mlcastle.net / (646) 382-7220 aolim: mlcastle / icq: 3520821 / yahoo: mlc000 please avoid sending me microsoft word, excel, or powerpoint documents. see http://www.gnu.org/philosophy/no-word-attachments.html for more info. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Brett Kelly bkelly@sourcereview.net This message has been digitally autographed using GnuPG. Open Source software will continue to change the world... http://www.opensource.org