packages feed

egison 2.3.6 → 2.3.7

raw patch · 5 files changed

+126/−172 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

egison.cabal view
@@ -1,5 +1,5 @@ Name:                egison-Version:             2.3.6+Version:             2.3.7 Synopsis:            An Interpreter for the Programming Language Egison Description:         An interpreter for the programming language Egison.                      A feature of Egison is the strong pattern match facility.
lib/core/array.egi view
@@ -5,14 +5,14 @@ (define $Array   (lambda [$a]     (type-      {[<cons ,$key ,$val _> [(Array a)]+      {[<cons ,$key ,$val> []         {[$arr (if (and (array-range? key arr)                         ((= a) (array-ref key arr) val))-                   {[arr]}+                   {[]}                    {})]}]-       [<cons ,$key _ _> [a (Array a)]+       [<cons ,$key _> [a]         {[$arr (if (array-range? key arr)-                   {[(array-ref key arr) arr]}+                   {[(array-ref key arr)]}                    {})]}]        [_ [Something]         {[$tgt {[tgt]}]}]
lib/core/number.egi view
@@ -102,6 +102,22 @@                          rs)                     0)})]}))) +(define $fib+  (lambda [$n]+    (match n Nat+      {[<o> 1]+       [<s <o>> 1]+       [<s <s $n1>> (+ (fib (+ n1 1)) (fib n1))]})))+++(define $fact+  (lambda [$n]+    (letrec {[$fact1 (lambda [$n $ret]+                       (match n [Nat]+                         {[<o> ret]+                          [<s $n1> (fact1 n1 (* n ret))]}))]}+      (fact1 n 1))))+ (define $Mod   (lambda [$m]     (type
sample/icfpc2012/mine.egi view
@@ -174,147 +174,125 @@           {[<left>             (match mine Mine               {-               [<cons ,[x y] <robot _>-                      <cons ,[(- x 1) y] <open-lift>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[(- x 1) y] <open-lift>>)                 <empty>]-               [<cons ,[x y] <open-lift>-                      <cons ,[(+ x 1) y] <robot _>-                            _>>+               [(& <cons ,[x y] <open-lift>>+                   <cons ,[(+ x 1) y] <robot _>>)                 <robot <goal>>]-               [<cons ,[x y] <robot _>-                      <cons ,[(- x 1) y] <lambda-stone>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[(- x 1) y] <lambda-stone>>)                 <empty>]-               [<cons ,[x y] <lambda-stone>-                      <cons ,[(+ x 1) y] <robot _>-                            _>>+               [(& <cons ,[x y] <lambda-stone>>+                   <cons ,[(+ x 1) y] <robot _>>)                 <robot <on-lambda>>]-               [<cons ,[x y] <robot _>-                      (| ^<cons ,[(- x 1) y] (| <wall> <rock _>) _>-                         <cons ,[(- x 1) y] <rock _>-                               <cons ,[(- x 2) y] <empty> _>>)>+               [(& <cons ,[x y] <robot _>>+                   (| ^<cons ,[(- x 1) y] (| <wall> <rock _>)>+                      (& <cons ,[(- x 1) y] <rock _>>+                         <cons ,[(- x 2) y] <empty>>)))                 <empty>]-               [<cons ,[(+ x 1) y] <robot _>-                      (| ^<cons ,[x y] (| <wall> <rock _>) _>-                         <cons ,[x y] <rock _>-                               <cons ,[(- x 1) y] <empty> _>>)>+               [(& <cons ,[(+ x 1) y] <robot _>>+                   (| ^<cons ,[x y] (| <wall> <rock _>)>+                      (& <cons ,[x y] <rock _>>+                         <cons ,[(- x 1) y] <empty>>)))                 <robot <normal>>]-               [<cons ,[x y] <empty>-                      <cons ,[(+ x 1) y] <rock _>-                            <cons ,[(+ x 2) y] <robot _>-                                  _>>>+               [(& <cons ,[x y] <empty>>+                   <cons ,[(+ x 1) y] <rock _>>+                   <cons ,[(+ x 2) y] <robot _>>)                 <rock #f>]-               [<cons ,[x y] <robot _>-                      _>+               [<cons ,[x y] <robot _>>                 <robot <normal>>]-               [<cons ,[x y] $tile _> tile]})]+               [<cons ,[x y] $tile> tile]})]            [<right>             (match mine Mine               {-               [<cons ,[x y] <robot _>-                      <cons ,[(+ x 1) y] <open-lift>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[(+ x 1) y] <open-lift>>)                 <empty>]-               [<cons ,[x y] <open-lift>-                      <cons ,[(- x 1) y] <robot _>-                            _>>+               [(& <cons ,[x y] <open-lift>>+                   <cons ,[(- x 1) y] <robot _>>)                 <robot <goal>>]-               [<cons ,[x y] <robot _>-                      <cons ,[(+ x 1) y] <lambda-stone>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[(+ x 1) y] <lambda-stone>>)                 <empty>]-               [<cons ,[x y] <lambda-stone>-                      <cons ,[(- x 1) y] <robot _>-                            _>>+               [(& <cons ,[x y] <lambda-stone>>+                   <cons ,[(- x 1) y] <robot _>>)                 <robot <on-lambda>>]-               [<cons ,[x y] <robot _>-                      (| ^<cons ,[(+ x 1) y] (| <wall> <rock _>) _>-                         <cons ,[(+ x 1) y] <rock _>-                               <cons ,[(+ x 2) y] <empty> _>>)>+               [(& <cons ,[x y] <robot _>>+                   (| ^<cons ,[(+ x 1) y] (| <wall> <rock _>)>+                      (& <cons ,[(+ x 1) y] <rock _>>+                         <cons ,[(+ x 2) y] <empty>>)))                 <empty>]-               [<cons ,[(- x 1) y] <robot _>-                      (| ^<cons ,[x y] (| <wall> <rock _>) _>-                         <cons ,[x y] <rock _>-                               <cons ,[(+ x 1) y] <empty> _>>)>+               [(& <cons ,[(- x 1) y] <robot _>>+                   (| ^<cons ,[x y] (| <wall> <rock _>)>+                      (& <cons ,[x y] <rock _>>+                         <cons ,[(+ x 1) y] <empty>>)))                 <robot <normal>>]-               [<cons ,[x y] <empty>-                      <cons ,[(- x 1) y] <rock _>-                            <cons ,[(- x 2) y] <robot _>-                                  _>>>+               [(& <cons ,[x y] <empty>>+                   <cons ,[(- x 1) y] <rock _>>+                   <cons ,[(- x 2) y] <robot _>>)                 <rock #f>]-               [<cons ,[x y] <robot _>-                      _>+               [<cons ,[x y] <robot _>>                 <robot <normal>>]-               [<cons ,[x y] $tile _> tile]})]+               [<cons ,[x y] $tile> tile]})]            [<up>             (match mine Mine               {-               [<cons ,[x y] <robot _>-                      <cons ,[x (+ y 1)] <open-lift>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[x (+ y 1)] <open-lift>>)                 <empty>]-               [<cons ,[x y] <open-lift>-                      <cons ,[x (- y 1)] <robot _>-                            _>>+               [(& <cons ,[x y] <open-lift>>+                   <cons ,[x (- y 1)] <robot _>>)                 <robot <goal>>]-               [<cons ,[x y] <robot _>-                      <cons ,[x (+ y 1)] <lambda-stone>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[x (+ y 1)] <lambda-stone>>)                 <empty>]-               [<cons ,[x y] <lambda-stone>-                      <cons ,[x (- y 1)] <robot _>-                            _>>+               [(& <cons ,[x y] <lambda-stone>>+                   <cons ,[x (- y 1)] <robot _>>)                 <robot <on-lambda>>]-               [<cons ,[x y] <robot _>-                      ^<cons ,[x (+ y 1)] (| <wall> <rock _>) _>>+               [(& <cons ,[x y] <robot _>>+                   ^<cons ,[x (+ y 1)] (| <wall> <rock _>)>)                 <empty>]-               [<cons ,[x (- y 1)] <robot _>-                      ^<cons ,[x y] (| <wall> <rock _>) _>>+               [(& <cons ,[x (- y 1)] <robot _>>+                   ^<cons ,[x y] (| <wall> <rock _>)>)                 <robot <normal>>]-               [<cons ,[x y] <robot _>-                      _>+               [<cons ,[x y] <robot _>>                 <robot <normal>>]-               [<cons ,[x y] $tile _> tile]})]+               [<cons ,[x y] $tile> tile]})]            [<down>             (match mine Mine               {-               [<cons ,[x y] <robot _>-                      <cons ,[x (- y 1)] <open-lift>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[x (- y 1)] <open-lift>>)                 <empty>]-               [<cons ,[x y] <open-lift>-                      <cons ,[x (+ y 1)] <robot _>-                            _>>+               [(& <cons ,[x y] <open-lift>>+                   <cons ,[x (+ y 1)] <robot _>>)                 <robot <goal>>]-               [<cons ,[x y] <robot _>-                      <cons ,[x (- y 1)] <lambda-stone>-                            _>>+               [(& <cons ,[x y] <robot _>>+                   <cons ,[x (- y 1)] <lambda-stone>>)                 <empty>]-               [<cons ,[x y] <lambda-stone>-                      <cons ,[x (+ y 1)] <robot _>-                            _>>+               [(& <cons ,[x y] <lambda-stone>>+                   <cons ,[x (+ y 1)] <robot _>>)                 <robot <on-lambda>>]-               [<cons ,[x y] <robot _>-                      ^<cons ,[x (- y 1)] (| <wall> <rock _>) _>>+               [(& <cons ,[x y] <robot _>>+                   ^<cons ,[x (- y 1)] (| <wall> <rock _>)>)                 <empty>]-               [<cons ,[x (+ y 1)] <robot _>-                      ^<cons ,[x y] (| <wall> <rock _>) _>>+               [(& <cons ,[x (+ y 1)] <robot _>>+                   ^<cons ,[x y] (| <wall> <rock _>)>)                 <robot <normal>>]-               [<cons ,[x y] <robot _>-                      _>+               [<cons ,[x y] <robot _>>                 <robot <normal>>]-               [<cons ,[x y] $tile _> tile]})]+               [<cons ,[x y] $tile> tile]})]            [<abort>             (match mine Mine-              {[<cons ,[x y] <robot _> _>+              {[<cons ,[x y] <robot _>>                 <robot <abort>>]-               [<cons ,[x y] $tile _> tile]})]+               [<cons ,[x y] $tile> tile]})]            [<wait>             (match mine Mine-              {[<cons ,[x y] <robot _> _>+              {[<cons ,[x y] <robot _>>                 <robot <normal>>]-               [<cons ,[x y] $tile _> tile]})]+               [<cons ,[x y] $tile> tile]})]            }))       (array-range mine))))                            @@ -323,49 +301,43 @@     (generate-array       (lambda [$x $y]         (match mine Mine-          {[<cons ,[x y] <empty>-                  <cons ,[x (+ y 1)] <rock _>-                        _>>+          {[(& <cons ,[x y] <empty>>+               <cons ,[x (+ y 1)] <rock _>>)             <rock #t>]-           [<cons ,[x (- y 1)] <empty>-                  <cons ,[x y] <rock _>-                        _>>+           [(& <cons ,[x (- y 1)] <empty>>+               <cons ,[x y] <rock _>>)             <empty>]-           [<cons ,[x y] <empty>-                  <cons ,[(- x 1) y] (| <rock _> <lambda-stone>)-                        <cons ,[(- x 1) (+ y 1)] <rock _>-                              <cons ,[x (+ y 1)] <empty>-                                    _>>>>+           [(& <cons ,[x y] <empty>>+               <cons ,[(- x 1) y] (| <rock _> <lambda-stone>)>+               <cons ,[(- x 1) (+ y 1)] <rock _>>+               <cons ,[x (+ y 1)] <empty>>)             <rock #t>]-           [<cons ,[x y] <rock _>-                  <cons ,[x (- y 1)] (| <rock _> <lambda-stone>)-                        <cons ,[(+ x 1) (- y 1)] <empty>-                              <cons ,[(+ x 1) y] <empty>-                                    _>>>>+           [(& <cons ,[x y] <rock _>>+               <cons ,[x (- y 1)] (| <rock _> <lambda-stone>)>+               <cons ,[(+ x 1) (- y 1)] <empty>>+               <cons ,[(+ x 1) y] <empty>>)             <empty>]-           [<cons ,[x y] <rock _>-                  <cons ,[x (- y 1)] <rock _>-                        (& (| <cons ,[(+ x 1) y] ^<empty> _>-                              <cons ,[(+ x 1) (- y 1)] ^<empty> _>)-                           <cons ,[(- x 1) (- y 1)] <empty>-                                 <cons ,[(- x 1) y] <empty>-                                       _>>)>>+           [(& <cons ,[x y] <rock _>>+               <cons ,[x (- y 1)] <rock _>>+               (| <cons ,[(+ x 1) y] ^<empty>>+                  <cons ,[(+ x 1) (- y 1)] ^<empty>>)+               <cons ,[(- x 1) (- y 1)] <empty>>+               <cons ,[(- x 1) y] <empty>>)             <empty>]-           [<cons ,[(+ x 1) (+ y 1)] <rock _>-                  <cons ,[(+ x 1) y] <rock _>-                        (& (| <cons ,[(+ x 2) y] ^<empty> _>-                              <cons ,[(+ x 2) (+ y 1)] ^<empty> _>)-                           <cons ,[x (+ y 1)] <empty>-                                 <cons ,[x y] <empty>-                                       _>>)>>+           [(& <cons ,[(+ x 1) (+ y 1)] <rock _>>+               <cons ,[(+ x 1) y] <rock _>>+               (| <cons ,[(+ x 2) y] ^<empty>>+                  <cons ,[(+ x 2) (+ y 1)] ^<empty>>)+               <cons ,[x (+ y 1)] <empty>>+               <cons ,[x y] <empty>>)             <rock #t>]-           [<cons ,[x y] <closed-lift> _>+           [<cons ,[x y] <closed-lift>>             (if (eq? 0 (size (lambda-stones mine)))                 <open-lift>                 <closed-lift>)]-           [<cons ,[x y] <rock _> _>+           [<cons ,[x y] <rock _>>                 <rock #f>]-           [<cons ,[x y] $tile _> tile]+           [<cons ,[x y] $tile> tile]            }))       (array-range mine)))) @@ -373,7 +345,7 @@   (lambda [$mine]     (concat (map (lambda [$x $y]                    (match mine Mine-                     {[<cons ,[x y] <lambda-stone> _> {[x y]}]+                     {[<cons ,[x y] <lambda-stone>> {[x y]}]                       [_ {}]}))                  (array-keys mine))))) @@ -382,11 +354,10 @@     (generate-array       (lambda [$x $y]         (match mine Mine-          {[<cons ,[x y] <robot <normal>>-                  <cons ,[x (+ y 1)] <rock ,#t>-                        _>>+          {[(& <cons ,[x y] <robot <normal>>>+               <cons ,[x (+ y 1)] <rock ,#t>>)             <robot <broken>>]-           [<cons ,[x y] $tile _> tile]+           [<cons ,[x y] $tile> tile]            }))       (array-range mine)))) 
sample/number-test.egi view
@@ -1,38 +1,5 @@-(define $fib-  (lambda [$n]-    (match n Nat-      {[<o> 1]-       [<s <o>> 1]-       [<s <s $n1>> (+ (fib (+ n1 1)) (fib n1))]})))- (test (fib 10)) -(define $fact-  (lambda [$n]-    (match n [Nat]-      {[<o> 1]-       [<s $n1> (* n (fact n1))]})))- (test (fact 10))--(define $min-  (lambda [$ns]-    (match ns (List Integer)-      {[<cons $n <nil>> n]-       [<cons $n $rs>-        (let {[$r (min rs)]}-          (match (compare-integer n r) Order-            {[<less> n]-             [_ r]}))]})))--(define $gcd-  (lambda [$ns]-    (let {[$ns2 ((remove-all Integer) ns 0)]}-      (match ns2 (Set Integer)-        {[<cons $n <nil>> n]-         [<cons ,(min ns2)-                $rs>-          (gcd {(min ns2) @(map (lambda [$r] (mod r (min ns2)))-                                rs)})]}))))  (test (gcd {10 20 40 35}))