Let's first discuss what a tuple is.
Here[1] it says, "A tuple is a fixed-size collection of values,
where each value can have a different type."
So they are of fixed-size and they can have values of different types. I am guessing the reason you want to use a tuple os that you want your collection object to be able to handle different types. But what about the fixed size bit?
If you want to just have those values in a collection, the easiest thing you can do is putting them into a list. The problem with lists is that the elements in them need to be of same type. If you just want every word, as a string, it is easy. If you want to have _either strings or ints_ within the list, then you need to define a data type which holds either strings or ints, and have a list of this type.
Just an example,
As luke requested
Here is the codes and some more brief explanation. Please help me
getItemFile :: IO String
getItemFile =
do
test <- readFile "input.txt"
return test
im taking a file data to a string
it contains string like “hello,world,I,am,a,new,developer”
so I need to put these each to a tuple. Because the content have Integers and Strings
sortList2 :: String -> String
sortList2 (x:xs)
| x == ',' = ""
| otherwise = [x] ++ sortList2 xs
Im breaking word by word from this above function
Now I need to send it to a tuple. Can someone help me how to do it. Is this possible. Using recursion im checking each word till “,” occurs
And taking that string and passing it to the tuple.
Can someone please help me to do it.
Please
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4918 (20100305) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe