plants-csv.scm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (require easy
  2. read-csv
  3. read-csv-util)
  4. (def (genus-alist)
  5. (let-pair ((titles rows)
  6. (force (csv-file-stream "genus.csv")))
  7. (assert
  8. (equal? titles
  9. '("Chord cardinality " "Plant family")))
  10. (=> rows
  11. (.map (lambda (row)
  12. (let-list ((card family) row)
  13. (cons (.symbol card)
  14. (.symbol family)))))
  15. F)))
  16. (def (plain-name->variable-name [string? str])
  17. (=> (.list str)
  18. (.map (lambda (c)
  19. (case c
  20. ((#\space) #\-)
  21. (else
  22. c))))
  23. .string))
  24. (def (variable-symbol->plain-name [symbol? str])
  25. (=> str
  26. .string
  27. .list
  28. (.map (lambda (c)
  29. (case c
  30. ((#\-) #\space)
  31. (else
  32. c))))
  33. .string))
  34. (TEST
  35. > (plain-name->variable-name "Foo bar")
  36. "Foo-bar"
  37. > (variable-symbol->plain-name (.symbol #))
  38. "Foo bar")
  39. "
  40. todo:
  41. - csv import
  42. - more aliases: all individual chords (but not the times (transpositions))
  43. - auto finding of names in chords
  44. (- maybe time of day functions for corresponding transpositions)
  45. "
  46. (def (species-alist)
  47. (let-pair ((titles rows) (force (csv-file-stream "species.csv")))
  48. (assert (equal? titles
  49. '("Set class" "Species")))
  50. (=> (.map rows
  51. (lambda (row)
  52. (if (read-csv-util:list-empty? row)
  53. (Nothing)
  54. (Just
  55. (let-list ((setclass species) row)
  56. (cons (call-with-input-string setclass read-all)
  57. (plain-name->variable-name
  58. (trim-both species))))))))
  59. F
  60. cat-Maybes)))