-2

OK so I have something that looks like this:

[Just [["Value1"],["","",""]],Just [["Value2"],["","","","","","","","","","","","","","","","","","","","","","","","","","","Value3",""]],Just [["Value4","",""]],Just [["Value5"],["","",""]],Just [["Value6"],["","",""]],Just []]

and I need to write all of those values to a LaTeX file, ignoring the empty strings(possibly in pairs, one line per pair).

How would I go to do that?

Thanks

EDIT: My file should look like this:

 Value1 Value2
 Value3 Value4
 Value5 Value6
BourbonCreams
  • 353
  • 4
  • 21
  • 1
    I'm not sure I understand what you want. Maybe it would help if you added the expected output latex source file for your example? – Alec Nov 29 '16 at 22:48
  • Well my file should look like this: Some String Some other value Again, some value more values Hey, a value a value appeared! Or better said: Value1 Value2 Value3 Value4 Value5 Value6 – BourbonCreams Nov 29 '16 at 22:51
  • I just edited the question, it should make more sense now. Thanks – BourbonCreams Nov 29 '16 at 22:57
  • Your input has unbalanced list delimiters (`[` and `]`) and string delimiters (`"`), and the list (of lists?) containing "Value4" isn't a `Maybe [[String]]` like the others. Please ensure the input is valid and clarify what parts are relevant to the transformation you want. – Sage Mitchell Nov 29 '16 at 23:06
  • Sorry that was my bad, I just fixed it. Thanks for pointing it out – BourbonCreams Nov 29 '16 at 23:22

1 Answers1

4
  1. Simplify your input to a [String] of the form ["Value1", "Value2", "Value3", "Value4", "Value5", "Value6"]. The functions catMaybes, concat, filter, and null may be helpful.
  2. Group your values into pairs. Depending on what you want, you may like to write this by hand or use chunksOf from the split package.
  3. Combine pairs with unwords; combine sets of pairs with unlines.
  4. Write to your file with writeFile.

Except where noted, all of these functions are in the standard library.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380