more tidy

This commit is contained in:
Vivianne 2023-12-03 04:57:58 -05:00
parent 26c426d528
commit 55e91e31ea

View file

@ -15,8 +15,10 @@
(/ (if "nine" "nin") "9"))
:main (any (thru :number))})
(defn pmatch [input] (peg/match peg input))
(defn first+last [input]
(var m (peg/match peg input))
(var m (pmatch input))
(scan-number
(string/join [(first m) (last m)])))
@ -25,10 +27,10 @@
(start-suite)
(assert (deep= @["1"] (peg/match peg "one")))
(assert (deep= @["1" "2"] (peg/match peg "onetwo")))
(assert (deep= @["1" "2" "3"] (peg/match peg "one2three")))
(assert (deep= @["8" "3"] (peg/match peg "eighthree")))
(assert (deep= @["1"] (pmatch "one")))
(assert (deep= @["1" "2"] (pmatch "onetwo")))
(assert (deep= @["1" "2" "3"] (pmatch "one2three")))
(assert (deep= @["8" "3"] (pmatch "eighthree")))
(def example
["two1nine"