Hi,

Im self learner in Haskell. And im stuck in a  small place which I tried
searching in google but couldn't find
Proper answer

I have some values in a string, Im removing them one by one from the string
(word by word) and I want to put them in a tuple. Because it contain
Integers and Strings.

Can someone help me

Maybe something like this?

pairs :: String -> [(String,Integer)]
pairs s = f (words s) [] where
   f [] acc = reverse acc
   f (i:[]) acc = reverse ((i,undefined):acc)
   f (i:v:r) acc = f r ((i,read v):acc)

Key points to look at:
   accumulator (acc with cons : ),
   recursion (f),
   pattern matching (i:v:r),
   undefined (if the data is not pairs).


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to