2010/3/8 Pradeep Wickramanayake <prad...@talk.lk>: > Hi, > > > > Im having problems with sending a string to a tuple. > > > > My string contains integers and strings > > > > The whole string stay as (“test,dfdf”,3,”dfsf”) > > > > sortList2 :: String -> String > > sortList2 (x:xs) > > | x == ',' = "" > > | otherwise = [x] ++ sortList2 xs > > > > The above function separating each words from the string > > > > Now I need to put them to a tuple > > > > putList :: String -> (Int, String, String, Int, Int) > > putList (x:xs) > > |xs /="" = sortList2 ++ > putList xs > >
I'm not sure what you're doing with the "sorting", but you could sort of hack it using `read' as such: Prelude> read "(3, \"hello\")" :: (Int, String) (3, "hello") Of course, this will crash if the input string is not parsable. Prelude> read "(3, 'a')" :: (Int, String) *** Exception: Prelude.read: no parse -- Deniz Dogan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe