Hello all,

I'm trying to write a function that takes a list and a element (same type) and
returns the index of the first instance of the element in the list.  like:
getindex "brett" 'e' would return 2, etc.

i'm trying to accomplish this using an accumulator, here's what i've got:

pyindex :: Eq a => a -> [a] -> Maybe Int
pyindex c l = pyindex' 0 chr (x:xs)
    where pyindex' count chr (x:xs) = do
        if x == chr 
          then return count
          else pyindex' (count + 1) chr xs

now, i know i've got a syntax problem, because i'm pretty sure my logic is
correct (or at least MOSTLY correct).

can anybody see what's wrong with my stuff?

thanks!
-- 
Brett Kelly
[EMAIL PROTECTED]
This message has been digitally autographed using GnuPG.

Vim - this ain't your daddy's text editor
http://www.vim.org

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to