patternmatching 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +10 -2
- data/examples/matching.rb +5 -3
- data/examples/partial_style_method.rb +4 -4
- data/examples/partial_style_method2.rb +3 -3
- data/lib/patternmatching/pattern.rb +4 -3
- data/lib/patternmatching/version.rb +1 -1
- data/website/index.html +14 -3
- data/website/index.txt +10 -2
- metadata +1 -1
data/README.txt
CHANGED
@@ -21,12 +21,19 @@ This module provides methods for tree pattern matching features.
|
|
21
21
|
* Syntax based on meta-programming, like "rspec", and so on.
|
22
22
|
|
23
23
|
Note: Default equivalence used in structured pattern matching is
|
24
|
-
based on "pattern === data",
|
24
|
+
based on "<code>pattern === data</code>",
|
25
|
+
so "<code>foo(Numeric)</code>" matches "<code>foo(100)</code>".
|
25
26
|
|
26
|
-
|
27
|
+
Notice: Current implementation is not thread safe now.
|
28
|
+
Need the receiver object(NOT an argument) calling pattern matching
|
29
|
+
synchronized when multi-threaded access.
|
27
30
|
|
28
31
|
h2. Demonstration of usage
|
29
32
|
|
33
|
+
Symbols(e.g. <code>:a</code>, <code>:right_value</code>)
|
34
|
+
in patterns is passed as variable
|
35
|
+
to the following block when the pattern matched.
|
36
|
+
|
30
37
|
<h3>Pattern matching expression</h3>
|
31
38
|
<pre>
|
32
39
|
require "patternmatching"
|
@@ -141,6 +148,7 @@ end # => "He is Jiro"
|
|
141
148
|
|
142
149
|
h2. Forum
|
143
150
|
|
151
|
+
Visit RubyForge project forum.
|
144
152
|
|
145
153
|
h2. How to submit patches
|
146
154
|
|
data/examples/matching.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
|
2
|
+
# If installed from gem
|
3
|
+
# require "rubygems"
|
4
|
+
# gem "patternmatching"
|
2
5
|
require "patternmatching"
|
3
6
|
|
4
|
-
|
5
7
|
# For DSL style code, include PatternMatching
|
6
8
|
include PatternMatching
|
7
9
|
|
8
10
|
# match example
|
9
11
|
def calc(code)
|
10
12
|
make (code) {
|
11
|
-
seems as {plus(:
|
12
|
-
seems as {mul(:
|
13
|
+
seems as {plus(:a, :b)} do calc(a) + calc(b) end
|
14
|
+
seems as {mul(:a, :b)} do calc(a) * calc(b) end
|
13
15
|
seems something do code end
|
14
16
|
}
|
15
17
|
end
|
@@ -9,11 +9,11 @@ class Calc
|
|
9
9
|
extend PatternMatching
|
10
10
|
|
11
11
|
# def calcm(o), as 3 partial styles
|
12
|
-
func(:calcm).seems as {plus(:
|
13
|
-
calcm(
|
12
|
+
func(:calcm).seems as {plus(:a, :b)} do
|
13
|
+
calcm(a) + calcm(b)
|
14
14
|
end
|
15
|
-
func(:calcm).seems as {mul(:
|
16
|
-
calcm(
|
15
|
+
func(:calcm).seems as {mul(:a, :b)} do
|
16
|
+
calcm(a) * calcm(b)
|
17
17
|
end
|
18
18
|
func(:calcm).seems as {:value} do
|
19
19
|
value
|
@@ -10,11 +10,11 @@ class CalcX
|
|
10
10
|
extend PatternMatching
|
11
11
|
|
12
12
|
func(:calcx) do
|
13
|
-
seems as {plus(:
|
14
|
-
calcx(
|
13
|
+
seems as {plus(:a, :b)} do
|
14
|
+
calcx(a) + calcx(b)
|
15
15
|
end
|
16
16
|
seems as {mul(:x, :y)} do
|
17
|
-
calcx(
|
17
|
+
calcx(a) * calcx(b)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
func(:calcx).seems as {:value} do
|
@@ -194,12 +194,13 @@ module PatternMatching
|
|
194
194
|
end
|
195
195
|
|
196
196
|
=begin
|
197
|
+
# If installed from rubygems
|
198
|
+
require "rubygems"
|
199
|
+
gem "patternmatching"
|
200
|
+
|
197
201
|
# for use
|
198
202
|
require "patternmatching"
|
199
203
|
|
200
|
-
# or from rubygems
|
201
|
-
require "rubygems"
|
202
|
-
gem "patternmatching"
|
203
204
|
|
204
205
|
# partial func example
|
205
206
|
class Calc
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>PatternMatching module</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/patternmatching"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/patternmatching" class="numbers">0.1.
|
36
|
+
<a href="http://rubyforge.org/projects/patternmatching" class="numbers">0.1.1</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘patternmatching’</h1>
|
39
39
|
|
@@ -67,15 +67,23 @@ Provides a pure ruby module that:
|
|
67
67
|
|
68
68
|
|
69
69
|
<p>Note: Default equivalence used in structured pattern matching is
|
70
|
-
based on “
|
70
|
+
based on “<code>pattern === data</code>”,
|
71
|
+
so “<code>foo(Numeric)</code>” matches “<code>foo(100)</code>”.</p>
|
71
72
|
|
72
73
|
|
73
|
-
<p>
|
74
|
+
<p>Notice: Current implementation is not thread safe now.
|
75
|
+
Need the receiver object(NOT an argument) calling pattern matching
|
76
|
+
synchronized when multi-threaded access.</p>
|
74
77
|
|
75
78
|
|
76
79
|
<h2>Demonstration of usage</h2>
|
77
80
|
|
78
81
|
|
82
|
+
<p>Symbols(e.g. <code>:a</code>, <code>:right_value</code>)
|
83
|
+
in patterns is passed as variable
|
84
|
+
to the following block when the pattern matched.</p>
|
85
|
+
|
86
|
+
|
79
87
|
<h3>Pattern matching expression</h3>
|
80
88
|
<pre>
|
81
89
|
require "patternmatching"
|
@@ -191,6 +199,9 @@ end # => "He is Jiro"
|
|
191
199
|
<h2>Forum</h2>
|
192
200
|
|
193
201
|
|
202
|
+
<p>Visit RubyForge project forum.</p>
|
203
|
+
|
204
|
+
|
194
205
|
<h2>How to submit patches</h2>
|
195
206
|
|
196
207
|
|
data/website/index.txt
CHANGED
@@ -21,12 +21,19 @@ This module provides methods for tree pattern matching features.
|
|
21
21
|
* Syntax based on meta-programming, like "rspec", and so on.
|
22
22
|
|
23
23
|
Note: Default equivalence used in structured pattern matching is
|
24
|
-
based on "pattern === data",
|
24
|
+
based on "<code>pattern === data</code>",
|
25
|
+
so "<code>foo(Numeric)</code>" matches "<code>foo(100)</code>".
|
25
26
|
|
26
|
-
|
27
|
+
Notice: Current implementation is not thread safe now.
|
28
|
+
Need the receiver object(NOT an argument) calling pattern matching
|
29
|
+
synchronized when multi-threaded access.
|
27
30
|
|
28
31
|
h2. Demonstration of usage
|
29
32
|
|
33
|
+
Symbols(e.g. <code>:a</code>, <code>:right_value</code>)
|
34
|
+
in patterns is passed as variable
|
35
|
+
to the following block when the pattern matched.
|
36
|
+
|
30
37
|
<h3>Pattern matching expression</h3>
|
31
38
|
<pre>
|
32
39
|
require "patternmatching"
|
@@ -141,6 +148,7 @@ end # => "He is Jiro"
|
|
141
148
|
|
142
149
|
h2. Forum
|
143
150
|
|
151
|
+
Visit RubyForge project forum.
|
144
152
|
|
145
153
|
h2. How to submit patches
|
146
154
|
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: patternmatching
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
6
|
+
version: 0.1.1
|
7
7
|
date: 2007-06-04 00:00:00 +09:00
|
8
8
|
summary: Provide a pure ruby module that can build structured objects easily, can enable pattern match of objects, and can define method as a partial function style.
|
9
9
|
require_paths:
|