egison 3.3.15 → 3.3.16
raw patch · 10 files changed
+130/−136 lines, 10 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- egison.cabal +2/−2
- elisp/egison-mode.el +1/−1
- hs-src/Language/Egison.hs +1/−1
- lib/core/base.egi +3/−3
- lib/core/collection.egi +0/−8
- lib/core/number.egi +2/−2
- lib/core/string.egi +114/−0
- lib/string/japanese.egi +5/−3
- lib/string/string.egi +0/−114
- sample/salesman.egi +2/−2
egison.cabal view
@@ -1,5 +1,5 @@ Name: egison-Version: 3.3.15+Version: 3.3.16 Synopsis: Programming language with non-linear pattern-matching against unfree data Description: An interpreter for Egison, the programming langugage that realized non-linear pattern-matching against unfree data types.@@ -32,7 +32,7 @@ Extra-Source-Files: benchmark/Benchmark.hs -Data-files: lib/core/base.egi lib/core/collection.egi lib/core/order.egi lib/core/number.egi lib/core/math.egi lib/core/database.egi lib/core/io.egi lib/string/string.egi lib/string/japanese.egi+Data-files: lib/core/base.egi lib/core/collection.egi lib/core/order.egi lib/core/number.egi lib/core/math.egi lib/core/database.egi lib/core/io.egi lib/core/string.egi lib/string/japanese.egi lib/tree/xml.egi lib/math/prime.egi lib/math/euler.egi sample/*.egi sample/io/*.egi sample/io/*.egi elisp/egison-mode.el
elisp/egison-mode.el view
@@ -183,7 +183,7 @@ (modify-syntax-entry ?\n ">" egison-mode-syntax-table) (modify-syntax-entry ?\? "w" egison-mode-syntax-table) (modify-syntax-entry ?# ". 14bn" egison-mode-syntax-table)- (modify-syntax-entry ?| ". 23bn" egison-mode-syntax-table)+ ;(modify-syntax-entry ?| ". 23bn" egison-mode-syntax-table) egison-mode-syntax-table) ;; (copy-syntax-table lisp-mode-syntax-table) "Syntax table for Egison mode")
hs-src/Language/Egison.hs view
@@ -112,5 +112,5 @@ , "lib/core/math.egi" , "lib/core/database.egi" , "lib/core/io.egi"- , "lib/string/string.egi"+ , "lib/core/string.egi" ]
lib/core/base.egi view
@@ -4,7 +4,7 @@ ;;;;; ;;;;; -(define $buildin-data-matcher+(define $builtin-data-matcher (matcher-dfs {[,$val [] {[$tgt (if (eq? val tgt)@@ -16,7 +16,7 @@ (define $id (lambda [$x] x)) -(define $bool buildin-data-matcher)+(define $bool builtin-data-matcher) (define $or (lambda [$b1 $b2]@@ -36,7 +36,7 @@ {[,#t #f] [,#f #t]}))) -(define $char buildin-data-matcher)+(define $char builtin-data-matcher) (define $eq?/m (lambda [$a $x $y]
lib/core/collection.egi view
@@ -130,14 +130,6 @@ {[<nil> init] [<cons $x $xs> (foldl fn (fn init x) xs)]}))) -(define $enumerate- (lambda [$fn $init $ls]- (match ls (list something)- {[<nil> {}]- [<cons $x $xs>- (let {[$ret (fn init x)]}- {ret @(enumerate fn ret xs)})]})))- (define $filter (lambda [$pred $xs] (foldr (lambda [$y $ys] (if (pred y) {y @ys} ys))
lib/core/number.egi view
@@ -91,7 +91,7 @@ ;;; ;;; Integers ;;;-(define $integer buildin-data-matcher)+(define $integer builtin-data-matcher) (define $power (lambda [$x $n]@@ -127,4 +127,4 @@ ;;; ;;; Float Numbers ;;;-(define $float buildin-data-matcher)+(define $float builtin-data-matcher)
+ lib/core/string.egi view
@@ -0,0 +1,114 @@+;;;;;+;;;;;+;;;;; String+;;;;;+;;;;;++(define $string+ (matcher+ {[,$val []+ {[$tgt (if (eq? val tgt)+ {[]}+ {})]}]+ [<nil> []+ {[$tgt (if (eq? "" tgt)+ {[]}+ {})]}]+ [<cons $ $> [char string]+ {[$tgt (if (eq? "" tgt)+ {}+ {(uncons-string tgt)})]}]+ [<join $ <cons ,$px $>> [string string]+ {[$tgt (match-all (S.split (pack {px}) tgt) (list string)+ [<join (& ^<nil> $xs) (& ^<nil> $ys)> [(S.intercalate (pack {px}) xs)+ (S.intercalate (pack {px}) ys)+ ]])]}]+ [<join $ <join ,$pxs $>> [string string]+ {[$tgt (match-all (S.split pxs tgt) (list string)+ [<join (& ^<nil> $xs) (& ^<nil> $ys)> [(S.intercalate pxs xs)+ (S.intercalate pxs ys)+ ]])]}]+ [<join $ $> [string string]+ {[$tgt (match-all tgt string+ [(loop $i [1 $n] <cons $xa_i ...> $rs) [(pack (map (lambda [$i] xa_i) (between 1 n))) rs]])]}]+ [$ [something]+ {[$tgt {tgt}]}]+ }))++(define $chop+ (lambda [$xs]+ (match xs string+ {[<snoc (| ,'\n' ,' ') $ys> (chop ys)]+ [_ xs]})))++;;;+;;; String as Collection+;;;++(define $S.empty?+ (lambda [$xs]+ (eq? xs "")))++(define $S.map+ (lambda [$f $xs]+ (pack (map f (unpack xs)))))++(define $S.length+ (lambda [$xs]+ (length-string xs)))++(define $S.split+ (lambda [$in $ls]+ (split-string in ls)))++(define $S.append+ (lambda [$xs $ys]+ (append-string xs ys)))++(define $S.concat+ (lambda [$xss]+ (foldr (lambda [$xs $rs] (S.append xs rs))+ ""+ xss)))++(define $S.intercalate (compose intersperse S.concat))++(define $alphabet?+ (match-lambda char+ {[,'a' #t] [,'b' #t] [,'c' #t] [,'d' #t] [,'e' #t]+ [,'f' #t] [,'g' #t] [,'h' #t] [,'i' #t] [,'j' #t]+ [,'k' #t] [,'l' #t] [,'m' #t] [,'n' #t] [,'o' #t]+ [,'p' #t] [,'q' #t] [,'r' #t] [,'s' #t] [,'t' #t]+ [,'u' #t] [,'v' #t] [,'w' #t] [,'x' #t] [,'y' #t]+ [,'z' #t]+ [,'A' #t] [,'B' #t] [,'C' #t] [,'D' #t] [,'E' #t]+ [,'F' #t] [,'G' #t] [,'H' #t] [,'I' #t] [,'J' #t]+ [,'K' #t] [,'L' #t] [,'M' #t] [,'N' #t] [,'O' #t]+ [,'P' #t] [,'Q' #t] [,'R' #t] [,'S' #t] [,'T' #t]+ [,'U' #t] [,'V' #t] [,'W' #t] [,'X' #t] [,'Y' #t]+ [,'Z' #t]+ [_ #f]}))++(define $alphabets?+ (lambda [$s]+ (all alphabet? (unpack s))))++(define $upper-case+ (match-lambda char+ {[,'a' 'A'] [,'b' 'B'] [,'c' 'C'] [,'d' 'D'] [,'e' 'E']+ [,'f' 'F'] [,'g' 'G'] [,'h' 'H'] [,'i' 'I'] [,'j' 'J']+ [,'k' 'K'] [,'l' 'L'] [,'m' 'M'] [,'n' 'N'] [,'o' 'O']+ [,'p' 'P'] [,'q' 'Q'] [,'r' 'R'] [,'s' 'S'] [,'t' 'T']+ [,'u' 'U'] [,'v' 'V'] [,'w' 'W'] [,'x' 'X'] [,'y' 'Y']+ [,'z' 'Z']+ [$c c]}))++(define $lower-case+ (match-lambda char+ {[,'A' 'a'] [,'B' 'b'] [,'C' 'c'] [,'D' 'd'] [,'E' 'e']+ [,'F' 'f'] [,'G' 'g'] [,'H' 'h'] [,'I' 'i'] [,'J' 'j']+ [,'K' 'k'] [,'L' 'l'] [,'M' 'm'] [,'N' 'n'] [,'O' 'o']+ [,'P' 'p'] [,'Q' 'q'] [,'R' 'r'] [,'S' 's'] [,'T' 't']+ [,'U' 'u'] [,'V' 'v'] [,'W' 'w'] [,'X' 'x'] [,'Y' 'y']+ [,'Z' 'z']+ [$c c]}))
lib/string/japanese.egi view
@@ -15,10 +15,11 @@ [,'ダ' #t] [,'ヂ' #t] [,'ヅ' #t] [,'デ' #t] [,'ド' #t] [,'バ' #t] [,'ビ' #t] [,'ブ' #t] [,'ベ' #t] [,'ボ' #t] [,'パ' #t] [,'ピ' #t] [,'プ' #t] [,'ペ' #t] [,'ポ' #t]- [,'ヴ' #t] [,'ヰ' #t]+ [,'ヴ' #t] [,'ヰ' #t] [,'ヱ' #t] [,'ァ' #t] [,'ィ' #t] [,'ゥ' #t] [,'ェ' #t] [,'ォ' #t]+ [,'ヵ' #t] [,'ヶ' #t] [,'ャ' #t] [,'ュ' #t] [,'ョ' #t]- [,'ッ' #t] [,'ー' #t]+ [,'ッ' #t] [,'ー' #t] [,'ヮ' #t] [_ #f]})) (define $katakanas?@@ -113,6 +114,7 @@ [,{'ダ'} {"D" "A"}] [,{'ヂ'} {"D" "I"}] [,{'ヅ'} {"D" "U"}] [,{'デ'} {"D" "E"}] [,{'ド'} {"D" "O"}] [,{'バ'} {"B" "A"}] [,{'ビ'} {"B" "I"}] [,{'ブ'} {"B" "U"}] [,{'ベ'} {"B" "E"}] [,{'ボ'} {"B" "O"}] [,{'パ'} {"P" "A"}] [,{'ピ'} {"P" "I"}] [,{'プ'} {"P" "U"}] [,{'ペ'} {"P" "E"}] [,{'ポ'} {"P" "O"}]- [,{'ヴ'} {"V" "U"}] [,{'ヮ'} {"W" "A"}] [,{'ヰ'} {"I"}]+ [,{'ヴ'} {"V" "U"}] [,{'ヰ'} {"I"}] [,{'ヱ'} {"E"}] [,{'ヮ'} {"W" "A"}]+ [,{'ヵ'} {"K" "A"}] [,{'ヶ'} {"K" "E"}] })))
− lib/string/string.egi
@@ -1,114 +0,0 @@-;;;;;-;;;;;-;;;;; String-;;;;;-;;;;;--(define $string- (matcher- {[,$val []- {[$tgt (if (eq? val tgt)- {[]}- {})]}]- [<nil> []- {[$tgt (if (eq? "" tgt)- {[]}- {})]}]- [<cons $ $> [char string]- {[$tgt (if (eq? "" tgt)- {}- {(uncons-string tgt)})]}]- [<join $ <cons ,$px $>> [string string]- {[$tgt (match-all (S.split (pack {px}) tgt) (list string)- [<join (& ^<nil> $xs) (& ^<nil> $ys)> [(S.intercalate (pack {px}) xs)- (S.intercalate (pack {px}) ys)- ]])]}]- [<join $ <join ,$pxs $>> [string string]- {[$tgt (match-all (S.split pxs tgt) (list string)- [<join (& ^<nil> $xs) (& ^<nil> $ys)> [(S.intercalate pxs xs)- (S.intercalate pxs ys)- ]])]}]- [<join $ $> [string string]- {[$tgt (match-all tgt string- [(loop $i [1 $n] <cons $xa_i ...> $rs) [(pack (map (lambda [$i] xa_i) (between 1 n))) rs]])]}]- [$ [something]- {[$tgt {tgt}]}]- }))--(define $chop- (lambda [$xs]- (match xs string- {[<snoc (| ,'\n' ,' ') $ys> (chop ys)]- [_ xs]})))--;;;-;;; String as Collection-;;;--(define $S.empty?- (lambda [$xs]- (eq? xs "")))--(define $S.map- (lambda [$f $xs]- (pack (map f (unpack xs)))))--(define $S.length- (lambda [$xs]- (length-string xs)))--(define $S.split- (lambda [$in $ls]- (split-string in ls)))--(define $S.append- (lambda [$xs $ys]- (append-string xs ys)))--(define $S.concat- (lambda [$xss]- (foldr (lambda [$xs $rs] (S.append xs rs))- ""- xss)))--(define $S.intercalate (compose intersperse S.concat))--(define $alphabet?- (match-lambda char- {[,'a' #t] [,'b' #t] [,'c' #t] [,'d' #t] [,'e' #t]- [,'f' #t] [,'g' #t] [,'h' #t] [,'i' #t] [,'j' #t]- [,'k' #t] [,'l' #t] [,'m' #t] [,'n' #t] [,'o' #t]- [,'p' #t] [,'q' #t] [,'r' #t] [,'s' #t] [,'t' #t]- [,'u' #t] [,'v' #t] [,'w' #t] [,'x' #t] [,'y' #t]- [,'z' #t]- [,'A' #t] [,'B' #t] [,'C' #t] [,'D' #t] [,'E' #t]- [,'F' #t] [,'G' #t] [,'H' #t] [,'I' #t] [,'J' #t]- [,'K' #t] [,'L' #t] [,'M' #t] [,'N' #t] [,'O' #t]- [,'P' #t] [,'Q' #t] [,'R' #t] [,'S' #t] [,'T' #t]- [,'U' #t] [,'V' #t] [,'W' #t] [,'X' #t] [,'Y' #t]- [,'Z' #t]- [_ #f]}))--(define $alphabets?- (lambda [$s]- (all alphabet? (unpack s))))--(define $upper-case- (match-lambda char- {[,'a' 'A'] [,'b' 'B'] [,'c' 'C'] [,'d' 'D'] [,'e' 'E']- [,'f' 'F'] [,'g' 'G'] [,'h' 'H'] [,'i' 'I'] [,'j' 'J']- [,'k' 'K'] [,'l' 'L'] [,'m' 'M'] [,'n' 'N'] [,'o' 'O']- [,'p' 'P'] [,'q' 'Q'] [,'r' 'R'] [,'s' 'S'] [,'t' 'T']- [,'u' 'U'] [,'v' 'V'] [,'w' 'W'] [,'x' 'X'] [,'y' 'Y']- [,'z' 'Z']- [$c c]}))--(define $lower-case- (match-lambda char- {[,'A' 'a'] [,'B' 'b'] [,'C' 'c'] [,'D' 'd'] [,'E' 'e']- [,'F' 'f'] [,'G' 'g'] [,'H' 'h'] [,'I' 'i'] [,'J' 'j']- [,'K' 'k'] [,'L' 'l'] [,'M' 'm'] [,'N' 'n'] [,'O' 'o']- [,'P' 'p'] [,'Q' 'q'] [,'R' 'r'] [,'S' 's'] [,'T' 't']- [,'U' 'u'] [,'V' 'v'] [,'W' 'w'] [,'X' 'x'] [,'Y' 'y']- [,'Z' 'z']- [$c c]}))
sample/salesman.egi view
@@ -22,9 +22,9 @@ (loop $i [2 5] <cons [,s_(- i 1) <cons [$s_i $p_i] _>] ...>- <cons [(& ,"錦糸町" ,s_5) _]+ <cons [,s_5 <cons [(& ,"東京" $s_6) $p_6] _>] _>)>- [(sum (map (lambda [$i] p_i) (between 1 5)))+ [(sum (map (lambda [$i] p_i) (between 1 6))) s]])) (define $main