Hi,
I'm a really beginner to haskell and I have a question about using classes. I don't now really what this function does. So I will try to use it to see what it will put out
position :: ( Enum a , Eq b ) => b -> [b] -> [a] position x = position_snd . zip ( enumFrom $ toEnum 1 ) where position_snd [] = [] position_snd ((p,y):ys) | x == y = p : position_snd ys | otherwise = position_snd ys
My roblem is now that I don't know how to use it.
I tried "head position 2 [1,2,3,4]" but I always get an error.
Try this:
head (position 33 [11,22,33,44,55]) :: Int
You need the () because otherwise head's argument is just position.
You need the ":: Int" because otherwise the type of the result is not determined-- on the command line there's not enough context to pick out one type from all the types in Enum.
Hope that helps,
--Ham -- ------------------------------------------------------------------ Hamilton Richards, PhD Department of Computer Sciences Senior Lecturer The University of Texas at Austin 512-471-9525 1 University Station C0500 Taylor Hall 5.138 Austin, Texas 78712-0233 [EMAIL PROTECTED] [EMAIL PROTECTED] ------------------------------------------------------------------ _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
