Skip to content

Instantly share code, notes, and snippets.

@ober
Created November 18, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ober/eb3e36e09e48eb99af85174c63719acf to your computer and use it in GitHub Desktop.
Save ober/eb3e36e09e48eb99af85174c63719acf to your computer and use it in GitHub Desktop.
Proper way to do the destructuring bind?
#!/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