Tony Davie wrote:
> 
> analyse "abbe" = an array, pos, such that pos ! 'a' == 0, pos ! 'b' ==1, pos !
> 'e' ==3, and all other pos ! i are -1 (say). [Note my correction to the
> specification below]

-- <CODE>

import Monad
import Array

firstIndexes :: (Ix a, Num b, Enum b) => (a,a) -> [a] -> Array a (Maybe
b)
firstIndexes bnds l = accumArray mplus Nothing bnds (zip l (map Just
[0..]))

analyse l = firstIndexes ('a','z') l

-- </CODE>

That's the most efficient way I know to do it in Haskell.

Matt Harden

Reply via email to