more tidy
This commit is contained in:
parent
26c426d528
commit
55e91e31ea
12
p01.janet
12
p01.janet
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue