egison 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ce8492a345ad492c9acb9e16c7c8d351a6b327
4
- data.tar.gz: 26f3f0aef845aaf21312713df5e418b724d4cbb0
3
+ metadata.gz: 146ed0f768555e2dc73b59c7468dc1d2dd0cfa6a
4
+ data.tar.gz: 8d4a4486865bff5cca675ac45117443b2da7e665
5
5
  SHA512:
6
- metadata.gz: 84f1a8ef64f513ea072ae2c6153c5bc3fd8868f065af6b74209797a949fe3573e0318a34f3de9b610003d76ee6745f8961c17856ca560be87f11e7e8bc20283e
7
- data.tar.gz: dd5c108d612a531bdde3b27ac1238af2ddd136259059eb9114f6f7af5304d140b24307119a485a45d37dfdbf26e5829d47b2538908b4b6909f349f1760d742c1
6
+ metadata.gz: dd3b48d5efa466113bae4eca3eb6e2f0bc5efb9405783a95f3d91bdad65d7b15a7aa4aad8d4859a36eebc3d30df245fa093a5caa69d3312d35069a5747965ccd
7
+ data.tar.gz: bd41119e0da423aa3b9fb66ca69c6bf03d25bb8e7a81fe9030de230ded0ffd7e10e82ab09f236e9d828c9ccf6de1abed9452322b3bfef697979daf2196aff144
data/README.md CHANGED
@@ -27,11 +27,13 @@ $ bundle install
27
27
 
28
28
  ## Basic Usage
29
29
 
30
- The library provides `Kernel#match_all` and `Kernel#match`.
30
+ The library provides `Egison#match_all` and `Egison#match`.
31
31
 
32
32
  ```
33
33
  require 'egison'
34
34
 
35
+ include Egison
36
+
35
37
  match_all(object) do
36
38
  with(pattern) do
37
39
  ...
@@ -171,6 +173,8 @@ We can enumerates all combinations of the elements of a collection with pattern-
171
173
  ```
172
174
  require 'egison'
173
175
 
176
+ include Egison
177
+
174
178
  p(match_all([1,2,3,4,5]) do with(List.(*_, _x, *_, _y, *_)) { [x, y] } end)
175
179
  #=> [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5]]
176
180
 
@@ -188,6 +192,8 @@ Isn't it exciting?
188
192
  ```
189
193
  require 'egison'
190
194
 
195
+ include Egison
196
+
191
197
  def poker_hands cs
192
198
  match(cs) do
193
199
  with(Multiset.(_[_s, _n], _[__s, __("n+1")], _[__s, __("n+2")], _[__s, __("n+3")], _[__s, __("n+4")])) do
@@ -235,6 +241,8 @@ I believe it is also a really exciting demonstration.
235
241
  require 'egison'
236
242
  require 'prime'
237
243
 
244
+ include Egison
245
+
238
246
  twin_primes = match_stream(Prime) {
239
247
  with(List.(*_, _x, __("x + 2"), *_)) {
240
248
  [x, x + 2]
@@ -254,7 +262,6 @@ Egison is the pattern-matching oriented pure functional programming language.
254
262
  Actually, the original pattern-matching system of Egison is more powerful.
255
263
  For example, we can do following things in the original Egison.
256
264
 
257
- - We can pattern-match against infinite lists.
258
265
  - We can define new pattern-constructors.
259
266
  - We can modularize useful patterns.
260
267
 
@@ -444,8 +444,8 @@ module PatternMatch
444
444
  end
445
445
  end
446
446
 
447
- module Kernel
448
- private
447
+ module Egison
448
+ extend self
449
449
 
450
450
  def match_all(tgt, &block)
451
451
  env = PatternMatch.const_get(:Env).new(self, tgt)
@@ -1,3 +1,3 @@
1
1
  module Egison
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,5 +1,7 @@
1
1
  require 'egison'
2
2
 
3
+ include Egison
4
+
3
5
  p(match_all([1,2,3,4,5]) do with(List.(*_, _x, *_, _y, *_)) { [x, y] } end)
4
6
 
5
7
  p(match_all([1,2,3,4,5]) do with(List.(*_, _x, *_, _y, *_, _z, *_)) { [x, y, z] } end)
@@ -1,5 +1,7 @@
1
1
  require 'egison'
2
2
 
3
+ include Egison
4
+
3
5
  p(match_all([1,2,3,4,5]) do with(List.(*_hs, *_ts)) { [hs, ts] } end)
4
6
 
5
7
  p(match_all([1,2,3,4,5]) do with(Multiset.(*_hs, *_ts)) { [hs, ts] } end)
@@ -1,5 +1,7 @@
1
1
  require 'egison'
2
2
 
3
+ include Egison
4
+
3
5
  def poker_hands cs
4
6
  match(cs) do
5
7
  with(Multiset.(_[_s, _n], _[__s, __("n+1")], _[__s, __("n+2")], _[__s, __("n+3")], _[__s, __("n+4")])) do
@@ -1,3 +1,5 @@
1
1
  require 'egison'
2
2
 
3
+ include Egison
4
+
3
5
  p(match_all([1,2,3,4,5]) do with(Set.(_x,_y, *_)) { [x, y] } end)
@@ -1,6 +1,8 @@
1
1
  require 'egison'
2
2
  require 'prime'
3
3
 
4
+ include Egison
5
+
4
6
  p(match_stream(1..5){ with(List.(*_, _x, *_, _y, *_)) { [x, y] } }.to_a)
5
7
 
6
8
  twin_primes = match_stream(Prime) {
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'egison'
3
3
 
4
+ include Egison
5
+
4
6
  describe "sample" do
5
7
  describe "combination.rb" do
6
8
  it %q{match_all([1,2,3,4,5]) do with(List.(*_, _x, *_, _y, *_)) { [x, y] } end} do
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'egison'
3
3
 
4
+ include Egison
5
+
4
6
  describe "sample" do
5
7
  describe "join.rb" do
6
8
  it %q{match_all([1,2,3,4,5]) do with(List.(*_hs, *_ts)) { [hs, ts] } end} do
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'egison'
3
3
 
4
+ include Egison
5
+
4
6
  def poker_hands cs
5
7
  match_single(cs) do
6
8
  with(Multiset.(_[_s, _n], _[__s, __("n+1")], _[__s, __("n+2")], _[__s, __("n+3")], _[__s, __("n+4")])) do
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'egison'
3
3
 
4
+ include Egison
5
+
4
6
  describe "sample" do
5
7
  describe "set.rb" do
6
8
  it %q{match_all([1,2,3,4,5]) do with(Set.(_x,_y, *_)) { [x, y] } end} do
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
  require 'egison'
3
3
  require 'prime'
4
4
 
5
+ include Egison
6
+
5
7
  def twin_primes
6
8
  match_stream(Prime) {
7
9
  with(List.(*_, _x, __("x + 2"), *_)) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egison
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Egi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake