browser - How to print to stdout in Clojure without returning nil -
i making website , want know if there way return string of integers vector, each in own line. when rig code use apply str output can in browser goes -> [1 2 3 4] -> 1 2 3 4. want this:
1 2 3 4 . . .
when try each element on own line using println, pprint or format, blank under results header in browser. assume because of return nil. there way formatting need, results of output can copied , pasted excel file without user having format hand?
if you're explicitly looking output csv-data can read excel, recommend looking @ 1 of csv libraries data.csv. these libraries not handle formatting data strings quite tricky rules in csv around quoting.
example obtains string based on csv data:
user=> (def data [[1 2] [2 3] [3 4] [4 5]]) #'user/data user=> (with-out-str (write-csv *out* data)) "1,2\n2,3\n3,4\n4,5\n"
if want constrain narrowly problem list, 1 way (of many ways) interleave infinite sequence of newlines between each piece of data:
user=> (def data [1 2 3 4]) #'user/data user=> (apply str (interleave data (repeat \newline))) "1\n2\n3\n4\n"
Comments
Post a Comment