-
-
Save ober/eb3e36e09e48eb99af85174c63719acf to your computer and use it in GitHub Desktop.
Proper way to do the destructuring bind?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gxi | |
(import | |
:gerbil/gambit | |
:gerbil/gambit/ports | |
:std/format | |
:std/generic | |
:std/iter | |
:std/misc/list | |
:std/misc/ports | |
:std/sugar | |
:std/text/csv | |
:std/text/json) | |
(def test-csv "A,B,C,D,E,F,G | |
1,2,3,4,5,6,7 | |
foo,bar,baz,krunk,kaffe,deadbeef,feedface") | |
(def (main . args) | |
(let* ((data (call-with-input-string test-csv read-csv-lines)) | |
(header (car data)) | |
(results [])) | |
(for (line (cdr data)) | |
(with ([ | |
A | |
B | |
C | |
D | |
E | |
F | |
G | |
] line) | |
(set! results (cons (hash | |
("A" A) | |
("B" B) | |
("C" C) | |
("D" D) | |
("E" E) | |
("F" F) | |
("G" G)) | |
results)))) | |
(displayln (json-object->string results)))) | |
(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment