cartesian 0.6.0 → 0.6.2
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.
- data/History.txt +6 -0
- data/Manifest.txt +13 -35
- data/Rakefile +19 -3
- data/{lib → etc}/recursive.rb +0 -0
- data/index.html +7 -0
- data/lib/cartesian.rb +1 -1
- data/script/txt2html +4 -2
- data/website/doc/Array.html +172 -0
- data/website/doc/Cartesian.html +638 -0
- data/website/doc/CartesianIterator.html +672 -0
- data/website/doc/Enumerable.html +158 -0
- data/website/doc/GridSearch.html +292 -0
- data/website/doc/Iterable.html +306 -0
- data/website/doc/README_rdoc.html +220 -0
- data/website/doc/created.rid +4 -4
- data/website/doc/lib/cartesian_iterator_rb.html +52 -0
- data/website/doc/lib/cartesian_rb.html +56 -0
- data/website/doc/lib/grid_search_rb.html +52 -0
- data/website/doc/rdoc.css +706 -0
- data/website/index.html +3 -3
- data/website/template.html.erb +1 -1
- metadata +15 -37
- data/website/doc/classes/Array.html +0 -128
- data/website/doc/classes/Cartesian.html +0 -398
- data/website/doc/classes/Cartesian.src/M000020.html +0 -18
- data/website/doc/classes/Cartesian.src/M000021.html +0 -18
- data/website/doc/classes/Cartesian.src/M000022.html +0 -18
- data/website/doc/classes/Cartesian.src/M000023.html +0 -23
- data/website/doc/classes/Cartesian.src/M000026.html +0 -23
- data/website/doc/classes/Cartesian.src/M000027.html +0 -30
- data/website/doc/classes/CartesianIterator.html +0 -326
- data/website/doc/classes/CartesianIterator.src/M000001.html +0 -21
- data/website/doc/classes/CartesianIterator.src/M000002.html +0 -18
- data/website/doc/classes/CartesianIterator.src/M000003.html +0 -21
- data/website/doc/classes/CartesianIterator.src/M000005.html +0 -20
- data/website/doc/classes/CartesianIterator.src/M000008.html +0 -20
- data/website/doc/classes/CartesianIterator.src/M000009.html +0 -19
- data/website/doc/classes/CartesianIterator.src/M000012.html +0 -19
- data/website/doc/classes/CartesianIterator.src/M000013.html +0 -39
- data/website/doc/classes/Enumerable.html +0 -112
- data/website/doc/classes/GridSearch.html +0 -160
- data/website/doc/classes/GridSearch.src/M000014.html +0 -18
- data/website/doc/classes/GridSearch.src/M000015.html +0 -18
- data/website/doc/classes/Iterable.html +0 -176
- data/website/doc/classes/Iterable.src/M000016.html +0 -19
- data/website/doc/classes/Iterable.src/M000017.html +0 -19
- data/website/doc/classes/Iterable.src/M000018.html +0 -18
- data/website/doc/classes/Iterable.src/M000019.html +0 -18
- data/website/doc/classes/Range.html +0 -118
- data/website/doc/files/cartesian_iterator_rb.html +0 -101
- data/website/doc/files/cartesian_rb.html +0 -108
- data/website/doc/files/grid_search_rb.html +0 -101
- data/website/doc/fr_class_index.html +0 -33
- data/website/doc/fr_file_index.html +0 -29
- data/website/doc/fr_method_index.html +0 -54
- data/website/doc/rdoc-style.css +0 -208
data/website/index.html
CHANGED
@@ -31,9 +31,9 @@
|
|
31
31
|
<div id="main">
|
32
32
|
|
33
33
|
<h1></h1>
|
34
|
-
<div id="version" class="clickable" onclick='document.location = "http://
|
34
|
+
<div id="version" class="clickable" onclick='document.location = "http://github.com/adrianomitre/cartesian"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://
|
36
|
+
<a href="http://github.com/adrianomitre/cartesian" class="numbers">0.6.2</a>
|
37
37
|
</div>
|
38
38
|
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script><h1>cartesian</h1>
|
39
39
|
<h3>Cartesian products in Ruby</h3>
|
@@ -104,7 +104,7 @@ rake install_gem</pre>
|
|
104
104
|
</form>
|
105
105
|
</div>
|
106
106
|
<p class="coda">
|
107
|
-
<a href="
|
107
|
+
<a href="http://github.com/adrianomitre">Adriano Mitre</a>, 7th January 2011<br>
|
108
108
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
109
109
|
</p>
|
110
110
|
</div>
|
data/website/template.html.erb
CHANGED
@@ -37,7 +37,7 @@
|
|
37
37
|
</div>
|
38
38
|
<%= body %>
|
39
39
|
<p class="coda">
|
40
|
-
<a href="
|
40
|
+
<a href="http://github.com/adrianomitre">Adriano Mitre</a>, <%= modified.pretty %><br>
|
41
41
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
42
42
|
</p>
|
43
43
|
</div>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 2
|
9
|
+
version: 0.6.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Adriano Mitre
|
@@ -57,12 +57,13 @@ files:
|
|
57
57
|
- Wishlist.txt
|
58
58
|
- config/hoe.rb
|
59
59
|
- config/requirements.rb
|
60
|
+
- etc/recursive.rb
|
61
|
+
- index.html
|
60
62
|
- lib/cartesian.rb
|
61
63
|
- lib/cartesian/grid_search.rb
|
62
64
|
- lib/cartesian/version.rb
|
63
65
|
- lib/cartesian_iterator.rb
|
64
66
|
- lib/grid_search.rb
|
65
|
-
- lib/recursive.rb
|
66
67
|
- script/console
|
67
68
|
- script/destroy
|
68
69
|
- script/generate
|
@@ -75,42 +76,19 @@ files:
|
|
75
76
|
- test/test_grid_search.rb
|
76
77
|
- test/test_helper.rb
|
77
78
|
- test/test_suite.rb
|
78
|
-
- website/doc/
|
79
|
-
- website/doc/
|
80
|
-
- website/doc/
|
81
|
-
- website/doc/
|
82
|
-
- website/doc/
|
83
|
-
- website/doc/
|
84
|
-
- website/doc/
|
85
|
-
- website/doc/classes/Cartesian.src/M000027.html
|
86
|
-
- website/doc/classes/CartesianIterator.html
|
87
|
-
- website/doc/classes/CartesianIterator.src/M000001.html
|
88
|
-
- website/doc/classes/CartesianIterator.src/M000002.html
|
89
|
-
- website/doc/classes/CartesianIterator.src/M000003.html
|
90
|
-
- website/doc/classes/CartesianIterator.src/M000005.html
|
91
|
-
- website/doc/classes/CartesianIterator.src/M000008.html
|
92
|
-
- website/doc/classes/CartesianIterator.src/M000009.html
|
93
|
-
- website/doc/classes/CartesianIterator.src/M000012.html
|
94
|
-
- website/doc/classes/CartesianIterator.src/M000013.html
|
95
|
-
- website/doc/classes/Enumerable.html
|
96
|
-
- website/doc/classes/GridSearch.html
|
97
|
-
- website/doc/classes/GridSearch.src/M000014.html
|
98
|
-
- website/doc/classes/GridSearch.src/M000015.html
|
99
|
-
- website/doc/classes/Iterable.html
|
100
|
-
- website/doc/classes/Iterable.src/M000016.html
|
101
|
-
- website/doc/classes/Iterable.src/M000017.html
|
102
|
-
- website/doc/classes/Iterable.src/M000018.html
|
103
|
-
- website/doc/classes/Iterable.src/M000019.html
|
104
|
-
- website/doc/classes/Range.html
|
79
|
+
- website/doc/Array.html
|
80
|
+
- website/doc/Cartesian.html
|
81
|
+
- website/doc/CartesianIterator.html
|
82
|
+
- website/doc/Enumerable.html
|
83
|
+
- website/doc/GridSearch.html
|
84
|
+
- website/doc/Iterable.html
|
85
|
+
- website/doc/README_rdoc.html
|
105
86
|
- website/doc/created.rid
|
106
|
-
- website/doc/files/cartesian_iterator_rb.html
|
107
|
-
- website/doc/files/cartesian_rb.html
|
108
|
-
- website/doc/files/grid_search_rb.html
|
109
|
-
- website/doc/fr_class_index.html
|
110
|
-
- website/doc/fr_file_index.html
|
111
|
-
- website/doc/fr_method_index.html
|
112
87
|
- website/doc/index.html
|
113
|
-
- website/doc/
|
88
|
+
- website/doc/lib/cartesian_iterator_rb.html
|
89
|
+
- website/doc/lib/cartesian_rb.html
|
90
|
+
- website/doc/lib/grid_search_rb.html
|
91
|
+
- website/doc/rdoc.css
|
114
92
|
- website/index.html
|
115
93
|
- website/index.txt
|
116
94
|
- website/javascripts/rounded_corners_lite.inc.js
|
@@ -1,128 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Array</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Array</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/cartesian_rb.html">
|
59
|
-
cartesian.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
<a href="../files/cartesian_iterator_rb.html">
|
63
|
-
cartesian_iterator.rb
|
64
|
-
</a>
|
65
|
-
<br />
|
66
|
-
<a href="../files/grid_search_rb.html">
|
67
|
-
grid_search.rb
|
68
|
-
</a>
|
69
|
-
<br />
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
|
-
|
73
|
-
<tr class="top-aligned-row">
|
74
|
-
<td><strong>Parent:</strong></td>
|
75
|
-
<td>
|
76
|
-
Object
|
77
|
-
</td>
|
78
|
-
</tr>
|
79
|
-
</table>
|
80
|
-
</div>
|
81
|
-
<!-- banner header -->
|
82
|
-
|
83
|
-
<div id="bodyContent">
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<div id="contextContent">
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
</div>
|
92
|
-
|
93
|
-
|
94
|
-
</div>
|
95
|
-
|
96
|
-
|
97
|
-
<!-- if includes -->
|
98
|
-
<div id="includes">
|
99
|
-
<h3 class="section-bar">Included Modules</h3>
|
100
|
-
|
101
|
-
<div id="includes-list">
|
102
|
-
<span class="include-name"><a href="Cartesian.html">Cartesian</a></span>
|
103
|
-
<span class="include-name"><a href="Iterable.html">Iterable</a></span>
|
104
|
-
<span class="include-name"><a href="GridSearch.html">GridSearch</a></span>
|
105
|
-
</div>
|
106
|
-
</div>
|
107
|
-
|
108
|
-
<div id="section">
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
<!-- if method_list -->
|
118
|
-
|
119
|
-
|
120
|
-
</div>
|
121
|
-
|
122
|
-
|
123
|
-
<div id="validator-badges">
|
124
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
125
|
-
</div>
|
126
|
-
|
127
|
-
</body>
|
128
|
-
</html>
|
@@ -1,398 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Module: Cartesian</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Cartesian</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/cartesian_rb.html">
|
59
|
-
cartesian.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
</table>
|
66
|
-
</div>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<div id="contextContent">
|
74
|
-
|
75
|
-
<div id="description">
|
76
|
-
<p>
|
77
|
-
The <a href="Cartesian.html">Cartesian</a> module provide methods for the
|
78
|
-
calculation of the <a href="Cartesian.html#M000024">cartesian</a> producted
|
79
|
-
between two enumerable objects.
|
80
|
-
</p>
|
81
|
-
<p>
|
82
|
-
It can also be easily mixed in into any enumerable class, i.e. any class
|
83
|
-
with <a href="Enumerable.html">Enumerable</a> module mixed in. Notice that
|
84
|
-
the names of the methods for mixin are different.
|
85
|
-
</p>
|
86
|
-
<p>
|
87
|
-
Module:
|
88
|
-
</p>
|
89
|
-
<pre>
|
90
|
-
Cartesian::product(foo, bar)
|
91
|
-
</pre>
|
92
|
-
<p>
|
93
|
-
Mixin:
|
94
|
-
</p>
|
95
|
-
<pre>
|
96
|
-
foo.cartesian( bar )
|
97
|
-
</pre>
|
98
|
-
<p>
|
99
|
-
The module is automatically mixed in <a href="Array.html">Array</a> class.
|
100
|
-
</p>
|
101
|
-
<h2>Author</h2>
|
102
|
-
<p>
|
103
|
-
Adriano MITRE <adriano.mitre@gmail.com>
|
104
|
-
</p>
|
105
|
-
<h2>Example</h2>
|
106
|
-
<p>
|
107
|
-
as module
|
108
|
-
</p>
|
109
|
-
<pre>
|
110
|
-
require 'cartesian'
|
111
|
-
foo = [1, 2]
|
112
|
-
bar = ["a", "b"]
|
113
|
-
Cartesian::product(foo, bar) #=> [[1, "a"], [1, "b"], [2, "a"], [2, "b"]]
|
114
|
-
</pre>
|
115
|
-
<p>
|
116
|
-
as mixin
|
117
|
-
</p>
|
118
|
-
<pre>
|
119
|
-
require 'cartesian'
|
120
|
-
foo = [1, 2]
|
121
|
-
bar = ["a", "b"]
|
122
|
-
foo.cartesian(bar) #=> [[1, "a"], [1, "b"], [2, "a"], [2, "b"]]
|
123
|
-
</pre>
|
124
|
-
|
125
|
-
</div>
|
126
|
-
|
127
|
-
|
128
|
-
</div>
|
129
|
-
|
130
|
-
<div id="method-list">
|
131
|
-
<h3 class="section-bar">Methods</h3>
|
132
|
-
|
133
|
-
<div class="name-list">
|
134
|
-
<a href="#M000027">**</a>
|
135
|
-
<a href="#M000024">cartesian</a>
|
136
|
-
<a href="#M000022">joined_cartesian</a>
|
137
|
-
<a href="#M000021">joined_product</a>
|
138
|
-
<a href="#M000026">left_product</a>
|
139
|
-
<a href="#M000028">power!</a>
|
140
|
-
<a href="#M000020">product</a>
|
141
|
-
<a href="#M000025">right_product</a>
|
142
|
-
<a href="#M000023">x</a>
|
143
|
-
</div>
|
144
|
-
</div>
|
145
|
-
|
146
|
-
</div>
|
147
|
-
|
148
|
-
|
149
|
-
<!-- if includes -->
|
150
|
-
|
151
|
-
<div id="section">
|
152
|
-
|
153
|
-
|
154
|
-
<div id="constants-list">
|
155
|
-
<h3 class="section-bar">Constants</h3>
|
156
|
-
|
157
|
-
<div class="name-list">
|
158
|
-
<table summary="Constants">
|
159
|
-
<tr class="top-aligned-row context-row">
|
160
|
-
<td class="context-item-name">VERSION</td>
|
161
|
-
<td>=</td>
|
162
|
-
<td class="context-item-value">'0.5.0'</td>
|
163
|
-
</tr>
|
164
|
-
</table>
|
165
|
-
</div>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
<!-- if method_list -->
|
174
|
-
<div id="methods">
|
175
|
-
<h3 class="section-bar">Public Class methods</h3>
|
176
|
-
|
177
|
-
<div id="method-M000021" class="method-detail">
|
178
|
-
<a name="M000021"></a>
|
179
|
-
|
180
|
-
<div class="method-heading">
|
181
|
-
<a href="Cartesian.src/M000021.html" target="Code" class="method-signature"
|
182
|
-
onclick="popupCode('Cartesian.src/M000021.html');return false;">
|
183
|
-
<span class="method-name">joined_product</span><span class="method-args">(first, second)</span>
|
184
|
-
</a>
|
185
|
-
</div>
|
186
|
-
|
187
|
-
<div class="method-description">
|
188
|
-
<p>
|
189
|
-
Behaves as <a href="Cartesian.html#M000020">product</a>, except for the
|
190
|
-
elements are joined.
|
191
|
-
</p>
|
192
|
-
<pre>
|
193
|
-
Cartesian::joined_cartesian( [1,2], %w(A B) ) #=> ["1A", "1B", "2A", "2B"]
|
194
|
-
</pre>
|
195
|
-
<p>
|
196
|
-
or, if mixed in into <a href="Array.html">Array</a>,
|
197
|
-
</p>
|
198
|
-
<pre>
|
199
|
-
[1,2].joined_cartesian %w(A B) #=> ["1A", "1B", "2A", "2B"]
|
200
|
-
</pre>
|
201
|
-
</div>
|
202
|
-
</div>
|
203
|
-
|
204
|
-
<div id="method-M000020" class="method-detail">
|
205
|
-
<a name="M000020"></a>
|
206
|
-
|
207
|
-
<div class="method-heading">
|
208
|
-
<a href="Cartesian.src/M000020.html" target="Code" class="method-signature"
|
209
|
-
onclick="popupCode('Cartesian.src/M000020.html');return false;">
|
210
|
-
<span class="method-name">product</span><span class="method-args">(first, second)</span>
|
211
|
-
</a>
|
212
|
-
</div>
|
213
|
-
|
214
|
-
<div class="method-description">
|
215
|
-
<p>
|
216
|
-
Produces the <a href="Cartesian.html#M000024">cartesian</a> <a
|
217
|
-
href="Cartesian.html#M000020">product</a> of self and other. The result is
|
218
|
-
an array of pairs (i.e. two-element arrays).
|
219
|
-
</p>
|
220
|
-
<pre>
|
221
|
-
Cartesian::product( [1,2], %w(A B) ) #=> [[1, "A"], [1, "B"], [2, "A"], [2, "B"]]
|
222
|
-
</pre>
|
223
|
-
<p>
|
224
|
-
or, if mixed in into <a href="Array.html">Array</a>,
|
225
|
-
</p>
|
226
|
-
<pre>
|
227
|
-
[1,2].cartesian %w(A B) #=> [[1, "A"], [1, "B"], [2, "A"], [2, "B"]]
|
228
|
-
</pre>
|
229
|
-
</div>
|
230
|
-
</div>
|
231
|
-
|
232
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
233
|
-
|
234
|
-
<div id="method-M000027" class="method-detail">
|
235
|
-
<a name="M000027"></a>
|
236
|
-
|
237
|
-
<div class="method-heading">
|
238
|
-
<a href="Cartesian.src/M000027.html" target="Code" class="method-signature"
|
239
|
-
onclick="popupCode('Cartesian.src/M000027.html');return false;">
|
240
|
-
<span class="method-name">**</span><span class="method-args">(fixnum)</span>
|
241
|
-
</a>
|
242
|
-
</div>
|
243
|
-
|
244
|
-
<div class="method-description">
|
245
|
-
<p>
|
246
|
-
Concise way of iterating multi-dimensionally over the same array or range.
|
247
|
-
</p>
|
248
|
-
<p>
|
249
|
-
For instance,
|
250
|
-
</p>
|
251
|
-
<pre>
|
252
|
-
for x,y,z in [0,1]**3
|
253
|
-
puts [x, y, z].join(',')
|
254
|
-
end
|
255
|
-
</pre>
|
256
|
-
<p>
|
257
|
-
produces the following output
|
258
|
-
</p>
|
259
|
-
<pre>
|
260
|
-
0,0,0
|
261
|
-
0,0,1
|
262
|
-
0,1,0
|
263
|
-
0,1,1
|
264
|
-
1,0,0
|
265
|
-
1,0,1
|
266
|
-
1,1,0
|
267
|
-
1,1,1
|
268
|
-
</pre>
|
269
|
-
<p>
|
270
|
-
It also works with <a href="Range.html">Range</a> objects.
|
271
|
-
</p>
|
272
|
-
</div>
|
273
|
-
</div>
|
274
|
-
|
275
|
-
<div id="method-M000024" class="method-detail">
|
276
|
-
<a name="M000024"></a>
|
277
|
-
|
278
|
-
<div class="method-heading">
|
279
|
-
<span class="method-name">cartesian</span><span class="method-args">(other)</span>
|
280
|
-
</div>
|
281
|
-
|
282
|
-
<div class="method-description">
|
283
|
-
<p>
|
284
|
-
Alias for <a href="Cartesian.html#M000023">x</a>
|
285
|
-
</p>
|
286
|
-
</div>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
<div id="method-M000022" class="method-detail">
|
290
|
-
<a name="M000022"></a>
|
291
|
-
|
292
|
-
<div class="method-heading">
|
293
|
-
<a href="Cartesian.src/M000022.html" target="Code" class="method-signature"
|
294
|
-
onclick="popupCode('Cartesian.src/M000022.html');return false;">
|
295
|
-
<span class="method-name">joined_cartesian</span><span class="method-args">(other)</span>
|
296
|
-
</a>
|
297
|
-
</div>
|
298
|
-
|
299
|
-
<div class="method-description">
|
300
|
-
<p>
|
301
|
-
<a href="Cartesian.html#M000021">Cartesian.joined_product</a> for mixin.
|
302
|
-
</p>
|
303
|
-
</div>
|
304
|
-
</div>
|
305
|
-
|
306
|
-
<div id="method-M000026" class="method-detail">
|
307
|
-
<a name="M000026"></a>
|
308
|
-
|
309
|
-
<div class="method-heading">
|
310
|
-
<a href="Cartesian.src/M000026.html" target="Code" class="method-signature"
|
311
|
-
onclick="popupCode('Cartesian.src/M000026.html');return false;">
|
312
|
-
<span class="method-name">left_product</span><span class="method-args">(other)</span>
|
313
|
-
</a>
|
314
|
-
</div>
|
315
|
-
|
316
|
-
<div class="method-description">
|
317
|
-
</div>
|
318
|
-
</div>
|
319
|
-
|
320
|
-
<div id="method-M000028" class="method-detail">
|
321
|
-
<a name="M000028"></a>
|
322
|
-
|
323
|
-
<div class="method-heading">
|
324
|
-
<span class="method-name">power!</span><span class="method-args">(fixnum)</span>
|
325
|
-
</div>
|
326
|
-
|
327
|
-
<div class="method-description">
|
328
|
-
<p>
|
329
|
-
Alias for #**
|
330
|
-
</p>
|
331
|
-
</div>
|
332
|
-
</div>
|
333
|
-
|
334
|
-
<div id="method-M000025" class="method-detail">
|
335
|
-
<a name="M000025"></a>
|
336
|
-
|
337
|
-
<div class="method-heading">
|
338
|
-
<span class="method-name">right_product</span><span class="method-args">(other)</span>
|
339
|
-
</div>
|
340
|
-
|
341
|
-
<div class="method-description">
|
342
|
-
<p>
|
343
|
-
Alias for <a href="Cartesian.html#M000023">x</a>
|
344
|
-
</p>
|
345
|
-
</div>
|
346
|
-
</div>
|
347
|
-
|
348
|
-
<div id="method-M000023" class="method-detail">
|
349
|
-
<a name="M000023"></a>
|
350
|
-
|
351
|
-
<div class="method-heading">
|
352
|
-
<a href="Cartesian.src/M000023.html" target="Code" class="method-signature"
|
353
|
-
onclick="popupCode('Cartesian.src/M000023.html');return false;">
|
354
|
-
<span class="method-name">x</span><span class="method-args">(other)</span>
|
355
|
-
</a>
|
356
|
-
</div>
|
357
|
-
|
358
|
-
<div class="method-description">
|
359
|
-
<p>
|
360
|
-
Convenient way of iterating over the elements. Preferable when the <a
|
361
|
-
href="Cartesian.html#M000024">cartesian</a> <a
|
362
|
-
href="Cartesian.html#M000020">product</a> array is not needed, for the
|
363
|
-
consumption of memory is fixed and very small, in contrast with the
|
364
|
-
exponential memory requirements of the conventional approach.
|
365
|
-
</p>
|
366
|
-
<pre>
|
367
|
-
for row, col in (1..10).x(1..30)
|
368
|
-
Matrix[row, col] = row**2 + col**3
|
369
|
-
end
|
370
|
-
</pre>
|
371
|
-
<p>
|
372
|
-
Of course, calls can be chained as in
|
373
|
-
</p>
|
374
|
-
<pre>
|
375
|
-
for x, y, z in (1..10).x(1..10).x(1..10)
|
376
|
-
# ... do something ...
|
377
|
-
end
|
378
|
-
</pre>
|
379
|
-
<p>
|
380
|
-
Beware that both <tt>self</tt> and <tt>other</tt> must implement
|
381
|
-
<tt>to_a</tt>, i.e., be convertible to array.
|
382
|
-
</p>
|
383
|
-
</div>
|
384
|
-
</div>
|
385
|
-
|
386
|
-
|
387
|
-
</div>
|
388
|
-
|
389
|
-
|
390
|
-
</div>
|
391
|
-
|
392
|
-
|
393
|
-
<div id="validator-badges">
|
394
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
395
|
-
</div>
|
396
|
-
|
397
|
-
</body>
|
398
|
-
</html>
|