fold - Foldr issues (Haskell) -


I am trying to convert from a table that is type of ([Char, Int]) < / Code> tab2str :: table for a string - & gt; String (which adheres to a specific formatting pattern.)

I am using plateau (as the title means), but I have to use the exact function to do something Problems are coming - that is, my errors look like this:

tab2str xs = foldr (++) '' $ map (\ char count -> 4 ++ ' : '++ show calculation ++' N ') xs

Output table should be each letter, one colon, then \ n on one Can be a string:

Tab 2 Strct Test 1 == "F: 1 \ n: 1 \ nl: 1 \ nd: 1 \ nr: 1 \ n"

Where test1 == [(F, 1), (O, 1), (L, 1), (D, 1), (R, 1)]

Any help has been received with gratitude.

After the following minor fixes:

  tab2str xs = foldr (++) $ Map (\ (char, count) -> & gt; show four ++: "++ show count ++" \ n ") xs   

one ?? ?? But whatever you want does not produce that much.

You might think this better:

  tab2 String table = CONSATAT $ map format table where formula (four, count) = [four] ++ ":" ++ Show count ++ "\ n"   

Then your test example:

  ghci & gt; Test 1 = [('F', 1), ('O', 1), ('L', 1), ('D', 1), ('R', 1)] GB & gt; Tab 2 String Test 1 "F: 1 \ No: 1 \ nl: 1 \ nd: 1 \ nr: 1 \ n" Gaasi & GT; PutStr $ tab2str test1F: 1O: 1L: 1D: 1R: 1GSC & gt;    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -