diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b27efd..25a8d49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * New builtin: `\lastValue`. * A new mode `last` is added. It outputs the last possible result. You can switch to this mode by the `-t` flag in the command line or the `\Mode last` command in the REPL. +* Now input can have leading and trailing spaces. The interpreter will trim them when parsing. ### Breaking changes diff --git a/analysis/corpus.txt b/analysis/corpus.txt index 0edf10c..74b8e57 100644 --- a/analysis/corpus.txt +++ b/analysis/corpus.txt @@ -164,6 +164,7 @@ oĉ~z Ħ± ᵉᵑ{ˣ∙ɔᵈç}T ᵐĈ +ˡ{v¦ Ṁ→ᵒÇ∏ƃ ʷ{į1?-ň O:Ŝ≡$Ðål diff --git a/analysis/freq_1gram.txt b/analysis/freq_1gram.txt index 0b9feb2..62c4feb 100644 --- a/analysis/freq_1gram.txt +++ b/analysis/freq_1gram.txt @@ -1,4 +1,4 @@ -{ : 82 +{ : 83 $ : 56 = : 55 : : 50 @@ -61,6 +61,7 @@ q : 12 ∆ : 12 _ : 12 ʷ : 11 +ˡ : 11 Ţ : 11 Q : 11 r : 11 @@ -69,7 +70,6 @@ r : 11 ∏ : 11 J : 11 ũ : 10 -ˡ : 10 E : 10 ≥ : 10 ŋ : 10 @@ -100,6 +100,7 @@ H : 8 £ : 8 Ø : 8 ɗ : 8 +¦ : 8 ƒ : 8 4 : 8 ¿ : 8 @@ -109,10 +110,10 @@ H : 8 / : 7 Ħ : 7 Ĭ : 7 -¦ : 7 Ĉ : 7 ä : 7 Ř : 7 +v : 7 ¢ : 7 ᵏ : 6 Ö : 6 @@ -136,7 +137,6 @@ D : 6 0 : 6 B : 6 b : 6 -v : 6 ƀ : 5 I : 5 y : 5 diff --git a/analysis/freq_2gram.txt b/analysis/freq_2gram.txt index 21c346d..b4ecce2 100644 --- a/analysis/freq_2gram.txt +++ b/analysis/freq_2gram.txt @@ -1,7 +1,7 @@ ᶦ{ : 12 ᵖ{ : 11 ʷ{ : 9 -ˡ{ : 8 +ˡ{ : 9 ᶠ{ : 7 {$ : 6 ᵑ{ : 6 @@ -184,6 +184,7 @@ $đ : 2 ∙+ : 2 ᵖf : 2 _= : 2 +{v : 2 -ň : 2 0* : 2 $ᶻ : 2 @@ -637,6 +638,7 @@ j1 : 1 ç} : 1 }T : 1 ᵐĈ : 1 +v¦ : 1 →ᵒ : 1 ᵒÇ : 1 Ç∏ : 1 @@ -1329,7 +1331,6 @@ h= : 1 Ť$ : 1 $ḟ : 1 0ʷ : 1 -{v : 1 v< : 1 <Ë : 1 Ë} : 1 diff --git a/analysis/freq_3gram.txt b/analysis/freq_3gram.txt index b43def8..7097f1e 100644 --- a/analysis/freq_3gram.txt +++ b/analysis/freq_3gram.txt @@ -440,6 +440,8 @@ j1Ĉ : 1 ɔᵈç : 1 ᵈç} : 1 ç}T : 1 +ˡ{v : 1 +{v¦ : 1 Ṁ→ᵒ : 1 →ᵒÇ : 1 ᵒÇ∏ : 1 diff --git a/analysis/freq_4gram.txt b/analysis/freq_4gram.txt index 080df44..bb00f97 100644 --- a/analysis/freq_4gram.txt +++ b/analysis/freq_4gram.txt @@ -294,6 +294,7 @@ oĉ~z : 1 ∙ɔᵈç : 1 ɔᵈç} : 1 ᵈç}T : 1 +ˡ{v¦ : 1 Ṁ→ᵒÇ : 1 →ᵒÇ∏ : 1 ᵒÇ∏ƃ : 1 diff --git a/analysis/particles.txt b/analysis/particles.txt index d4c1464..f4bf909 100644 --- a/analysis/particles.txt +++ b/analysis/particles.txt @@ -20,6 +20,6 @@ particle : with "{" / total ᵏ : 4 / 6 ᶠ : 7 / 10 ʸ : 3 / 4 -ˡ : 8 / 10 +ˡ : 9 / 11 ʷ : 9 / 11 ᶦ : 12 / 13 diff --git a/app/Main.hs b/app/Main.hs index 66d35bd..e4d5992 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -115,7 +115,13 @@ data RunOnce = RunOnce } optRunOnce :: Parser RunOnce -optRunOnce = RunOnce <$> optCode <*> optInput <*> optMode <*> optMultiple <*> optLimit +optRunOnce = + RunOnce + <$> optCode + <*> optInput + <*> optMode + <*> optMultiple + <*> optLimit data Opts = Opts RunOnce | Repl | DocBuiltin | DocCodePage | Version diff --git a/src/Nekomata/Parser/Data.hs b/src/Nekomata/Parser/Data.hs index f6ed8d8..959e2fc 100644 --- a/src/Nekomata/Parser/Data.hs +++ b/src/Nekomata/Parser/Data.hs @@ -124,8 +124,9 @@ parseData' = -- | Parse a Nekomata input parseInput :: Parser [Data] parseInput = - parseData - `endBy` (try (spaces >> char ',' >> spaces) <|> spaces) - <* spaces - <* eof - "Nekomata input" + spaces + >> parseData + `endBy` (try (spaces >> char ',' >> spaces) <|> spaces) + <* spaces + <* eof + "Nekomata input" diff --git a/test/Eval.hs b/test/Eval.hs index 50c1ae8..23c4750 100644 --- a/test/Eval.hs +++ b/test/Eval.hs @@ -1780,6 +1780,18 @@ testEval = describe "Solutions to Code Golf Stack Exchange challenges" $ do , ("[1,2,2,4,4,4,4]", all_ ["[1,2,2,4,4,4,4]"]) , ("[1,2,2,1,4,8,1]", all_ ["[3,2,2,3,1,1,3]"]) ] + describe "q224278: Count the trailing zeros" $ do + specEval + "ˡ{v¦" + [ ("512 2", all_ ["9"]) + , ("248 2", all_ ["3"]) + , ("364 265", all_ ["0"]) + , ("764 2", all_ ["2"]) + , ("336 284", all_ ["0"]) + , ("517 422", all_ ["0"]) + , ("554 37", all_ ["0"]) + , ("972 3", all_ ["5"]) + ] describe "q225203: Delannoy numbers" $ do specEval "Ṁ→ᵒÇ∏ƃ"