
I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a new line. If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]] Can anyone help me figure this out? Thanks.

Is this what you need?
print $ foldl (++) [] [["abc", "cde"], ["fgh", "ghi"]]
-deech
On Thu, Oct 22, 2009 at 2:11 PM, Chandni Navani
I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a new line.
If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]]
Can anyone help me figure this out? Thanks.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Sorry, forgot about the newline. How's this?
mapM putStrLn $ concat [["abc", "cde"], ["fgh", "ghi"]]
-deech
On Thu, Oct 22, 2009 at 9:53 PM, aditya siram
Is this what you need?
print $ foldl (++) [] [["abc", "cde"], ["fgh", "ghi"]]
-deech
On Thu, Oct 22, 2009 at 2:11 PM, Chandni Navani
wrote: I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a o line.
If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]]
Can anyone help me figure this out? Thanks.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Is it possible to set the Command Arguments when running the main function in ghci? Thanks, Kui _________________________________________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/soc...

:set args foo bar
should work. FYI, type :? to ghci to see all commands.
HTH
-nwn
2009/10/23 Kui Ma
Is it possible to set the Command Arguments when running the main function in ghci?
Thanks, Kui
________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

or
:ma foo bar
On Fri, Oct 23, 2009 at 7:40 PM, Yusaku Hashimoto
:set args foo bar
should work. FYI, type :? to ghci to see all commands.
HTH
-nwn
2009/10/23 Kui Ma
: Is it possible to set the Command Arguments when running the main function in ghci?
Thanks, Kui
________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Thank you very much!
Date: Fri, 23 Oct 2009 19:40:46 +0900 Subject: Re: [Haskell-beginners] how to set command args in ghci From: nonowarn@gmail.com To: mklklk@hotmail.com CC: beginners@haskell.org
:set args foo bar
should work. FYI, type :? to ghci to see all commands.
HTH
-nwn
2009/10/23 Kui Ma
: Is it possible to set the Command Arguments when running the main function in ghci?
Thanks, Kui
________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_________________________________________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/soc...

On Thu, Oct 22, 2009 at 9:11 PM, Chandni Navani
I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a new line.
If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]]
Can anyone help me figure this out? Thanks.
You can use unlines and concat :
putStr . unlines . concat $ [["abc", "cde"] ["fgh", "ghi"]]
-- Jedaï

On Thu, Oct 22, 2009 at 12:11:07PM -0700, Chandni Navani wrote:
I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a new line.
If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]]
Can anyone help me figure this out? Thanks.
Most of the other solutions I've seen people post would output something like abc cde fgh ghi But if you actually want brackets and quotes etc. to show the structure, you could do something like putStrLn . bracket . intercalate ",\n " . map (bracket . intercalate ",\n " . map show) where bracket x = "[" ++ x ++ "]" Just transform the list step-by-step into the particular String you want as output. -Brent

Hi, seems to me like a job for `Text.PrettyPrint`: import Text.PrettyPrint ppString :: String -> Doc ppString = doubleQuotes . text ppList :: [Doc] -> Doc ppList = brackets . vcat . punctuate (text ",") pretty = ppList . map (ppList . map ppString) The code is hopefully almost self-explaining (`vcat` does the line breaking). The result looks as follows: *Main> pretty [["abc", "cde"], ["fgh", "ghi"]] [["abc", "cde"], ["fgh", "ghi"]] Sincerely, jan. On Thu, Oct 22, 2009 at 12:11:07PM -0700, Chandni Navani wrote:
I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a new line.
If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]]
Can anyone help me figure this out? Thanks.
-- Heriot-Watt University is a Scottish charity registered under charity number SC000278.
participants (7)
-
aditya siram
-
Brent Yorgey
-
Chaddaï Fouché
-
Chandni Navani
-
Jan Jakubuv
-
Kui Ma
-
Yusaku Hashimoto