Making all parameters optionals

If a parameter is not provided, it's set to nil
This commit is contained in:
teo3300
2024-06-25 18:27:23 +09:00
parent e7f55424b5
commit abb23a8b48
3 changed files with 17 additions and 6 deletions

View File

@ -52,6 +52,7 @@
(def! join (fn* [l s]
"Join element of list l to a stiring, using s as separator"
(def! s (or s ""))
(def! join-r (fn* [l t]
(if (empty? l)
t
@ -61,8 +62,10 @@
(def! chsub (fn* [s c1 c2]
(strc (map-if (fn* [x] (= x c1)) (fn* [x] c2) (boom s)))))
(def! parse-csv (fn* [filename]
(map (fn* [x] (split x ",")) (filter (fn* [x] (not (= x "")))(split (slurp filename) "\n")))))
(def! parse-csv (fn* [filename row-s col-s]
(def! col-s (or col-s "\n"))
(def! row-s (or row-s ","))
(map (fn* [x] (split x row-s)) (filter (fn* [x] (not (= x "")))(split (slurp filename) col-s)))))
(def! _toint {"0" 0 "1" 1
"2" 2 "3" 3