
20 Feb
2010
20 Feb
'10
11:39 a.m.
Hi, I have to write a function which maps a list of integers to a list of the corresponding nats. The following code is already there: data Nat = Z | S Nat deriving (Eq,Ord,Show) instance Enum Nat where toEnum i | i < 0 = error "Enum_Nat.toEnum: Negative integer" | i == 0 = Z | otherwise = S (toEnum (i-1)) the function should be: mapIntsToNats :: [Int] -> Maybe [Nat] so for example: [2,0,1,3] should make: [S (S Z), Z, S Z, S (S (S Z))] how can I do that? -- NEU: Mit GMX DSL über 1000,- ¿ sparen! http://portal.gmx.net/de/go/dsl02