cartesian 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,20 @@
1
- === 0.5.3 2011-01-04
1
+ === 0.6.0 2011-01-07
2
+
3
+ * 1 major enhancement:
4
+ * Cartesian is now included in Enumerable and in all classes and modules which
5
+ include it, so that any class or module that ever includes Enumerable will have
6
+ cartesian methods. New tests were also added to test the novel functionality.
7
+
8
+ * 7 minor, non-functional, enhancements:
9
+ * removed replication of VERSION in lib/cartesian.rb and lib/cartesian/version.rb
10
+ * fixed the "FIXME full name" in the website template
11
+ * created Rake task :render_website, which also regenerates RDoc documentation, ensuring its up-to-date
12
+ * documentation is now generated by Darkfish Rdoc and includes README.rdoc, as expected
13
+ * added Google Analytics tracking to the website
14
+ * deleted unnecessary test_suite.rb ('rake test' === 'ruby test/test_suite.rb')
15
+ * moved 'recursive.rb' to 'etc/' (related implementation by Brian Schröäer, not part of the gem)
16
+
17
+ === 0.5.3 2011-01-05
2
18
 
3
19
  * 3 minor enhancements:
4
20
  * code comment/documentation update
data/PostInstall.txt CHANGED
@@ -1,7 +1,4 @@
1
1
 
2
- For more information on cartesian, see http://cartesian.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
2
+ For more information on cartesian, see http://adrianomitre.github.com/cartesian/website/index.html
6
3
 
7
4
 
data/README.rdoc CHANGED
@@ -30,19 +30,26 @@ or use the methods provided by the mixin in the Array class
30
30
 
31
31
  which include the short'n'sweet _x_ method
32
32
  v = [] #=> []
33
- for a,b in [1,2].x [3,4]
33
+ for a, b in [1,2].x [3,4]
34
34
  v << [a,b]
35
35
  end #=> true
36
36
  v #=> [[1, 3], [1, 4], [2, 3], [2, 4]]
37
+ for x, y, z in 0..1
37
38
 
38
39
  The '**' operator provides a convenient way of iterating multi-dimensionally over the same array or range
39
- v = [0,1]**3 #=> #<CartesianIterator:0x7f2fb8e54978 @tot_iter=8, @lists=[[0, 1], [0, 1], [0, 1]]>
40
- v.to_a #=> [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
40
+ u = [0,1]**3 #=> #<CartesianIterator:0x7f2fb8e54978 @tot_iter=8, @lists=[[0, 1], [0, 1], [0, 1]]>
41
+ u.to_a #=> [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
42
+
43
+ v = []
44
+ for x, y, z in (0...10)**3
45
+ v << [x, y, z] if x*x + y*y + z*z == 6
46
+ end
47
+ v #=> [[1, 1, 2], [1, 2, 1], [2, 1, 1]]
41
48
 
42
49
  Finally, the grid search methods
43
- require 'grid_search'
50
+ require 'cartesian/grid_search'
44
51
  [-1, 0, 1, 2].argmax {|x| x**2 } #=> 2
45
- [-1, 0, 1, 2].argmin {|x| x.abs } #=> 0
52
+ 0.argmin {|x| x.abs } #=> 0
46
53
 
47
54
  == REQUIREMENTS:
48
55
 
@@ -56,7 +63,7 @@ Finally, the grid search methods
56
63
 
57
64
  (The MIT License)
58
65
 
59
- Copyright (c) 2011 Adriano Mitre <adriano.mitre@gmail.com>
66
+ Copyright (c) 2006-2011 Adriano Mitre <adriano.mitre@gmail.com>
60
67
 
61
68
  Permission is hereby granted, free of charge, to any person obtaining
62
69
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -23,4 +23,12 @@ Dir['tasks/**/*.rake'].each { |t| load t }
23
23
 
24
24
  # TODO - want other tests/tasks run by default? Add them to the list
25
25
  # remove_task :default
26
- # task :default => [:spec, :features]
26
+ # task :default => [:spec, :features]
27
+
28
+ task :render_website do |t|
29
+ Dir.chdir File.dirname(File.expand_path(__FILE__))
30
+ system %q{ script/txt2html website/index.txt website/template.html.erb > website/index.html }
31
+ system %q{ rdoc README.rdoc lib/*.rb }
32
+ system %q{ rm -rf website/doc; mv doc website }
33
+ end
34
+
data/Wishlist.txt CHANGED
@@ -1,3 +1,13 @@
1
+ = FIXME:
2
+
3
+ * Include README.rdoc in the website/doc (RDoc)
4
+
5
+ = SUGGESTIONS:
6
+
7
+ * Include information regarding the memory usage (vs other cartesian implementations):
8
+ * "Unfortunately, these methods use too much memory, storing the whole cartesian
9
+ product Array in memory even its elements are needed only one at a time."
10
+ src: http://www.ruby-forum.com/topic/95519
11
+
1
12
  * Release GridSearch as a separate, independent gem. Note that 'lib/grid_search.rb' is already independent.
2
- * Remove replication of VERSION in lib/cartesian.rb and lib/cartesian/version.rb due to parts of newgem 1.5.3 and older (DRY)
3
- * Fix/automate the FIXME in the website email (currently being fixed manually)
13
+
data/lib/cartesian.rb CHANGED
@@ -39,7 +39,7 @@ module Cartesian
39
39
  # Unfortunately, as of now, the version data must be replicated in ../cartesian.rb,
40
40
  # due to a mix of newgem versions, each requiring a different one. Not DRY :P
41
41
  #
42
- VERSION = "0.5.3"
42
+ VERSION = "0.6.0"
43
43
 
44
44
  # Produces the cartesian product of self and other.
45
45
  # The result is an array of pairs (i.e. two-element arrays).
@@ -156,13 +156,30 @@ module Cartesian
156
156
  end
157
157
  end
158
158
  alias :power! :**
159
- end
160
-
161
- class Array
162
- include Cartesian
163
- end
164
-
165
- class Range
166
- include Cartesian
159
+
160
+ # Sure, it would be great if +Enumerable.module_eval("include Cartesian")+ did the trick,
161
+ # but fact is that it would not work because of the [dynamic module include problem][1],
162
+ # so the following, less straightforward solution has to be applied.
163
+ #
164
+ # JRuby (at least up to version 1.5.6) has ObjectSpace disabled by default, so it needs
165
+ # to be enabled manually ([reference][2]).
166
+ #
167
+ # [1]: http://eigenclass.org/hiki/The+double+inclusion+problem "Dynamic Module Include Problem"
168
+ # [2]: http://ola-bini.blogspot.com/2007/07/objectspace-to-have-or-not-to-have.html "ObjectSpace: to have or not to have"
169
+ # [3]: http://www.ruby-forum.com/topic/160487 "problem of feedtools with jruby"
170
+ #
171
+ prev_jruby_objectspace_state = nil # only for scope reasons
172
+ if defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /jruby/i
173
+ require 'jruby'
174
+ prev_jruby_objectspace_state = JRuby.objectspace
175
+ JRuby.objectspace = true
176
+ end
177
+ ObjectSpace.each_object(Module) do |m|
178
+ if m <= Enumerable # equiv. to "if m.include?(Enumerable) || m == Enumerable"
179
+ m.module_eval("include Cartesian")
180
+ end
181
+ end
182
+ JRuby.objectspace = prev_jruby_objectspace_state if RUBY_DESCRIPTION =~ /jruby/i
183
+
167
184
  end
168
185
 
@@ -52,13 +52,13 @@ class CartesianIterator
52
52
  for list in @lists
53
53
  elems << list.restart_and_raw_next
54
54
  end
55
- if RUBY_VERSION <= '1.9.1'; yield *elems.map {|x| x }; else; yield *elems; end
55
+ if RUBY_VERSION <= '1.9.1'; yield(*elems.map {|x| x }); else; yield(*elems); end # Yeah, v.map{|x|x} should be equal to v, but strangely it is NOT in Ruby versions prior to 1.9.2.
56
56
 
57
57
  last_list_index = @lists.size-1
58
58
  n = last_list_index
59
59
  loop do
60
60
  if elems[n] = @lists[n].raw_next
61
- if RUBY_VERSION <= '1.9.1'; yield *elems.map {|x| x }; else; yield *elems; end
61
+ if RUBY_VERSION <= '1.9.1'; yield(*elems.map {|x| x }); else; yield(*elems); end # See previous comment.
62
62
  n = last_list_index
63
63
  next
64
64
  elsif n > 0
@@ -81,7 +81,7 @@ module Iterable
81
81
  end
82
82
 
83
83
  def next
84
- restart unless @next_index
84
+ restart unless defined? @next_index
85
85
  raw_next
86
86
  end
87
87
 
data/script/txt2html CHANGED
@@ -15,9 +15,9 @@ end
15
15
  require 'redcloth'
16
16
  require 'syntax/convertors/html'
17
17
  require 'erb'
18
- require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
18
+ require File.dirname(File.expand_path(__FILE__)) + "/../lib/#{GEM_NAME}.rb"
19
19
 
20
- version = Cartesian::VERSION::STRING
20
+ version = Cartesian::VERSION
21
21
  download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
22
 
23
23
  def rubyforge_project_id
@@ -30,9 +30,9 @@ class Fixnum
30
30
  return 'th' if (10..19).include?(self % 100)
31
31
  # others
32
32
  case self % 10
33
- when 1: return 'st'
34
- when 2: return 'nd'
35
- when 3: return 'rd'
33
+ when 1; return 'st'
34
+ when 2; return 'nd'
35
+ when 3; return 'rd'
36
36
  else return 'th'
37
37
  end
38
38
  end
@@ -19,6 +19,26 @@ class TestCartesian < Test::Unit::TestCase
19
19
  [2, 6], [3, 4], [3, 5], [3, 6]]
20
20
  assert(foo.x(bar).to_a == expected)
21
21
  assert(Cartesian.product(foo,bar) == expected)
22
+ end
23
+
24
+ def test_other_existing_enumerable
25
+ if RUBY_DESCRIPTION =~ /rubinius/i # Work around a Rubinius bug I found and [reported][1] and whose
26
+ foo = [0.0, 0.6] # [fix][2] has not yet been merged to HEAD (Jan 1st, 2011).
27
+ else # [1]: https://github.com/evanphx/rubinius/issues/issue/650
28
+ foo = 0.step(1, 0.6) # [2]: https://github.com/evanphx/rubinius/commit/9ad78eaaf66dac6615baa06a712594a95b1a7bea
29
+ end
30
+ bar = { :x => 42, :y => 43 }
31
+ expected = foo.to_a.x(bar.to_a).to_a
32
+ actual = foo.x(bar).to_a
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_other_new_enumerable
37
+ String.class_eval "alias each each_line ; include Enumerable"
38
+ foo = "foo\nbar"
39
+ bar = [1, 2]
40
+ expected = [["foo\n", 1], ["foo\n", 2], ["bar", 1], ["bar", 2]]
41
+ assert_equal expected, foo.x(bar).to_a
22
42
  end
23
43
 
24
44
  def test_product
@@ -44,9 +64,11 @@ class TestCartesian < Test::Unit::TestCase
44
64
  foo = 1..3
45
65
  bar = %w{a b c}
46
66
  expected = [[1, "a"], [1, "b"], [1, "c"], [2, "a"], [2, "b"],
47
- [2, "c"], [3, "a"], [3, "b"], [3, "c"]]
48
- assert(foo.x(bar).to_a == expected)
49
- assert(Cartesian.product(foo,bar) == expected) ##################
67
+ [2, "c"], [3, "a"], [3, "b"], [3, "c"]]
68
+ actual = foo.x(bar).to_a
69
+ assert_equal expected, actual
70
+ actual = Cartesian.product(foo,bar)
71
+ assert_equal expected, actual
50
72
  end
51
73
 
52
74
  def test_power
@@ -56,8 +78,9 @@ class TestCartesian < Test::Unit::TestCase
56
78
  assert_equal ary, ary**1
57
79
  expected = [[0, 0, 0], [0, 0, 1], [0, 1, 0],\
58
80
  [0, 1, 1], [1, 0, 0], [1, 0, 1],\
59
- [1, 1, 0], [1, 1, 1]]
60
- assert_equal expected, ([0,1]**3).to_a
81
+ [1, 1, 0], [1, 1, 1]]
82
+ actual = ([0,1]**3).to_a
83
+ assert_equal expected, actual
61
84
  end
62
85
 
63
86
  def test_joined_cartesian
@@ -1,10 +1,11 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper.rb')
2
- require File.join(File.dirname(__FILE__), 'extensions.rb')
3
-
1
+ %w{test_helper extensions}.each do |req|
2
+ require File.join(File.dirname(__FILE__), "#{req}.rb")
3
+ end
4
+
4
5
  class TestExtensions < Test::Unit::TestCase
5
6
  def test_among?
6
- assert 1.among?([1,2,3])
7
+ assert 1.among? [1,2,3]
7
8
  assert ! 7.among?([1,2,3])
8
- assert (3.0).among?([1,2,3])
9
+ assert 3.0.among? [1,2,3]
9
10
  end
10
11
  end
@@ -13,9 +13,9 @@ class TestCartesian < Test::Unit::TestCase
13
13
  assert_equal 0, *[-2,-1,0].argmax {|x| x**3 }
14
14
  values = []
15
15
  -3.step(3, 0.25) {|val| values << val }
16
- x, y = (values**2).argmax {|x,y| x**2+y**2 }
17
- assert x.among?([-3,3])
18
- assert y.among?([-3,3])
16
+ x2, y2 = (values**2).argmax {|x,y| x**2+y**2 }
17
+ assert x2.among?([-3,3])
18
+ assert y2.among?([-3,3])
19
19
  end
20
20
 
21
21
  end
@@ -1 +1,5 @@
1
- Tue, 04 Jan 2011 07:25:24 -0200
1
+ Fri, 07 Jan 2011 02:32:48 -0200
2
+ README.rdoc Fri, 07 Jan 2011 02:06:14 -0200
3
+ lib/cartesian.rb Fri, 07 Jan 2011 01:02:01 -0200
4
+ lib/cartesian_iterator.rb Thu, 06 Jan 2011 18:18:15 -0200
5
+ lib/grid_search.rb Wed, 05 Jan 2011 06:07:10 -0200
@@ -1,24 +1,124 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
5
4
 
6
- <!--
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
8
 
8
- RDoc Documentation
9
+ <title>RDoc Documentation</title>
10
+
11
+ <link type="text/css" media="screen" href="rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
16
+ <script src="js/darkfish.js" type="text/javascript" charset="utf-8"></script>
9
17
 
10
- -->
11
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
- <head>
13
- <title>RDoc Documentation</title>
14
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
18
  </head>
16
- <frameset rows="20%, 80%">
17
- <frameset cols="25%,35%,45%">
18
- <frame src="fr_file_index.html" title="Files" name="Files" />
19
- <frame src="fr_class_index.html" name="Classes" />
20
- <frame src="fr_method_index.html" name="Methods" />
21
- </frameset>
22
- <frame src="files/cartesian_rb.html" name="docwin" />
23
- </frameset>
24
- </html>
19
+ <body class="indexpage">
20
+
21
+
22
+ <h1>RDoc Documentation</h1>
23
+
24
+
25
+ <p>This is the API documentation for 'RDoc Documentation'.</p>
26
+
27
+
28
+
29
+
30
+ <h2>Files</h2>
31
+ <ul>
32
+
33
+ <li class="file"><a href="README_rdoc.html">README.rdoc</a></li>
34
+
35
+ </ul>
36
+
37
+
38
+ <h2 id="classes">Classes/Modules</h2>
39
+ <ul>
40
+
41
+ <li class="class"><a href="Array.html">Array</a></li>
42
+
43
+ <li class="module"><a href="Cartesian.html">Cartesian</a></li>
44
+
45
+ <li class="class"><a href="CartesianIterator.html">CartesianIterator</a></li>
46
+
47
+ <li class="module"><a href="Enumerable.html">Enumerable</a></li>
48
+
49
+ <li class="module"><a href="GridSearch.html">GridSearch</a></li>
50
+
51
+ <li class="module"><a href="Iterable.html">Iterable</a></li>
52
+
53
+ </ul>
54
+
55
+ <h2 id="methods">Methods</h2>
56
+ <ul>
57
+
58
+ <li><a href="Cartesian.html#method-c-joined_product">::joined_product &mdash; Cartesian</a></li>
59
+
60
+ <li><a href="CartesianIterator.html#method-c-new">::new &mdash; CartesianIterator</a></li>
61
+
62
+ <li><a href="Cartesian.html#method-c-product">::product &mdash; Cartesian</a></li>
63
+
64
+ <li><a href="Cartesian.html#method-i-%2A%2A">#** &mdash; Cartesian</a></li>
65
+
66
+ <li><a href="CartesianIterator.html#method-i-%3D%3D">#== &mdash; CartesianIterator</a></li>
67
+
68
+ <li><a href="GridSearch.html#method-i-argbest">#argbest &mdash; GridSearch</a></li>
69
+
70
+ <li><a href="GridSearch.html#method-i-argmax">#argmax &mdash; GridSearch</a></li>
71
+
72
+ <li><a href="GridSearch.html#method-i-argmin">#argmin &mdash; GridSearch</a></li>
73
+
74
+ <li><a href="Cartesian.html#method-i-cartesian">#cartesian &mdash; Cartesian</a></li>
75
+
76
+ <li><a href="CartesianIterator.html#method-i-dup">#dup &mdash; CartesianIterator</a></li>
77
+
78
+ <li><a href="CartesianIterator.html#method-i-each">#each &mdash; CartesianIterator</a></li>
79
+
80
+ <li><a href="CartesianIterator.html#method-i-equal">#equal &mdash; CartesianIterator</a></li>
81
+
82
+ <li><a href="Cartesian.html#method-i-joined_cartesian">#joined_cartesian &mdash; Cartesian</a></li>
83
+
84
+ <li><a href="Cartesian.html#method-i-left_product">#left_product &mdash; Cartesian</a></li>
85
+
86
+ <li><a href="CartesianIterator.html#method-i-left_product">#left_product &mdash; CartesianIterator</a></li>
87
+
88
+ <li><a href="CartesianIterator.html#method-i-left_product%21">#left_product! &mdash; CartesianIterator</a></li>
89
+
90
+ <li><a href="Iterable.html#method-i-next">#next &mdash; Iterable</a></li>
91
+
92
+ <li><a href="Cartesian.html#method-i-power%21">#power! &mdash; Cartesian</a></li>
93
+
94
+ <li><a href="CartesianIterator.html#method-i-product">#product &mdash; CartesianIterator</a></li>
95
+
96
+ <li><a href="CartesianIterator.html#method-i-product%21">#product! &mdash; CartesianIterator</a></li>
97
+
98
+ <li><a href="Iterable.html#method-i-raw_next">#raw_next &mdash; Iterable</a></li>
99
+
100
+ <li><a href="Iterable.html#method-i-restart">#restart &mdash; Iterable</a></li>
101
+
102
+ <li><a href="Iterable.html#method-i-restart_and_raw_next">#restart_and_raw_next &mdash; Iterable</a></li>
103
+
104
+ <li><a href="CartesianIterator.html#method-i-right_product">#right_product &mdash; CartesianIterator</a></li>
105
+
106
+ <li><a href="Cartesian.html#method-i-right_product">#right_product &mdash; Cartesian</a></li>
107
+
108
+ <li><a href="CartesianIterator.html#method-i-right_product%21">#right_product! &mdash; CartesianIterator</a></li>
109
+
110
+ <li><a href="CartesianIterator.html#method-i-x">#x &mdash; CartesianIterator</a></li>
111
+
112
+ <li><a href="Cartesian.html#method-i-x">#x &mdash; Cartesian</a></li>
113
+
114
+ <li><a href="CartesianIterator.html#method-i-x%21">#x! &mdash; CartesianIterator</a></li>
115
+
116
+ </ul>
117
+
118
+ <div id="validator-badges">
119
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
120
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
121
+ Rdoc Generator</a> 1.1.6</small>.</p>
122
+ </div>
123
+ </body>
124
+ </html>
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1></h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/cartesian"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/cartesian" class="numbers">0.5.3</a>
36
+ <a href="http://rubyforge.org/projects/cartesian" class="numbers">0.6.0</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>
@@ -60,15 +60,18 @@ It can also be easily and conveniently mixed-in into any enumerable class.</p>
60
60
  <p>which include the short&#8217;n&#8217;sweet <em>x</em> method</p>
61
61
  <p><pre class='syntax'>
62
62
  <span class="ident">v</span> <span class="punct">=</span> <span class="punct">[]</span> <span class="comment">#=&gt; []</span>
63
- <span class="keyword">for</span> <span class="ident">a</span><span class="punct">,</span><span class="ident">b</span> <span class="keyword">in</span> <span class="punct">[</span><span class="number">1</span><span class="punct">,</span><span class="number">2</span><span class="punct">].</span><span class="ident">x</span> <span class="punct">[</span><span class="number">3</span><span class="punct">,</span><span class="number">4</span><span class="punct">]</span>
63
+ <span class="keyword">for</span> <span class="ident">a</span><span class="punct">,</span> <span class="ident">b</span> <span class="keyword">in</span> <span class="punct">[</span><span class="number">1</span><span class="punct">,</span><span class="number">2</span><span class="punct">].</span><span class="ident">x</span> <span class="punct">[</span><span class="number">3</span><span class="punct">,</span><span class="number">4</span><span class="punct">]</span>
64
64
  <span class="ident">v</span> <span class="punct">&lt;&lt;</span> <span class="punct">[</span><span class="ident">a</span><span class="punct">,</span><span class="ident">b</span><span class="punct">]</span>
65
65
  <span class="keyword">end</span> <span class="comment">#=&gt; true</span>
66
66
  <span class="ident">v</span> <span class="comment">#=&gt; [[1, 3], [1, 4], [2, 3], [2, 4]]</span>
67
67
  </pre></p>
68
68
  <p>The &#8216;**&#8217; operator provides a convenient way of iterating multi-dimensionally over the same array or range</p>
69
69
  <p><pre class='syntax'>
70
- <span class="ident">v</span> <span class="punct">=</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span><span class="number">1</span><span class="punct">]**</span><span class="number">3</span> <span class="comment">#=&gt; #&lt;CartesianIterator:0x7f2fb8e54978 @tot_iter=8, @lists=[[0, 1], [0, 1], [0, 1]]&gt;</span>
71
- <span class="ident">v</span><span class="punct">.</span><span class="ident">to_a</span> <span class="comment">#=&gt; [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]</span>
70
+ <span class="ident">u</span> <span class="punct">=</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">1</span><span class="punct">]**</span><span class="number">3</span> <span class="comment">#=&gt; #&lt;CartesianIterator:0x7f2fb8e54978 @tot_iter=8, \</span>
71
+ <span class="comment"># @lists=[[0, 1], [0, 1], [0, 1]]&gt;</span>
72
+ <span class="ident">u</span><span class="punct">.</span><span class="ident">to_a</span> <span class="comment">#=&gt; [[0, 0, 0], [0, 0, 1], [0, 1, 0], \</span>
73
+ <span class="comment"># [0, 1, 1], [1, 0, 0], [1, 0, 1], \</span>
74
+ <span class="comment"># [1, 1, 0], [1, 1, 1]]</span>
72
75
  </pre></p>
73
76
  <p>Finally, the grid search methods</p>
74
77
  <p><pre class='syntax'>
@@ -92,19 +95,34 @@ rake install_gem</pre>
92
95
  <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
93
96
  <h2>Contact</h2>
94
97
  <p>Comments are welcome. Send an email to <a href="mailto:adriano.mitre@gmail.com">Adriano Mitre</a>.</p>
98
+ <div align=right>
95
99
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
96
100
  <input type="hidden" name="cmd" value="_s-xclick">
97
101
  <input type="hidden" name="hosted_button_id" value="9ABWULT73Y7AC">
98
102
  <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
99
103
  <p><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></p>
100
104
  </form>
105
+ </div>
101
106
  <p class="coda">
102
- <a href="adriano.mitre@gmail.com">Adriano Mitre</a>, 5th January 2011<br>
107
+ <a href="adriano.mitre@gmail.com">Adriano Mitre</a>, 7th January 2011<br>
103
108
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
104
109
  </p>
105
110
  </div>
106
111
 
107
112
  <!-- insert site tracking codes here, like Google Urchin -->
113
+ <script type="text/javascript">
114
+
115
+ var _gaq = _gaq || [];
116
+ _gaq.push(['_setAccount', 'UA-20605454-1']);
117
+ _gaq.push(['_trackPageview']);
118
+
119
+ (function() {
120
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
121
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
122
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
123
+ })();
124
+
125
+ </script>
108
126
 
109
127
  </body>
110
128
  </html>
data/website/index.txt CHANGED
@@ -39,7 +39,7 @@ which include the short'n'sweet _x_ method
39
39
 
40
40
  <pre syntax="ruby">
41
41
  v = [] #=> []
42
- for a,b in [1,2].x [3,4]
42
+ for a, b in [1,2].x [3,4]
43
43
  v << [a,b]
44
44
  end #=> true
45
45
  v #=> [[1, 3], [1, 4], [2, 3], [2, 4]]
@@ -48,8 +48,11 @@ v #=> [[1, 3], [1, 4], [2, 3], [2, 4]]
48
48
  The '**' operator provides a convenient way of iterating multi-dimensionally over the same array or range
49
49
 
50
50
  <pre syntax="ruby">
51
- v = [0,1]**3 #=> #<CartesianIterator:0x7f2fb8e54978 @tot_iter=8, @lists=[[0, 1], [0, 1], [0, 1]]>
52
- v.to_a #=> [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
51
+ u = [0, 1]**3 #=> #<CartesianIterator:0x7f2fb8e54978 @tot_iter=8, \
52
+ # @lists=[[0, 1], [0, 1], [0, 1]]>
53
+ u.to_a #=> [[0, 0, 0], [0, 0, 1], [0, 1, 0], \
54
+ # [0, 1, 1], [1, 0, 0], [1, 0, 1], \
55
+ # [1, 1, 0], [1, 1, 1]]
53
56
  </pre>
54
57
 
55
58
  Finally, the grid search methods
@@ -87,10 +90,11 @@ h2. Contact
87
90
 
88
91
  Comments are welcome. Send an email to "Adriano Mitre":mailto:adriano.mitre@gmail.com.
89
92
 
93
+ <div align=right>
90
94
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
91
95
  <input type="hidden" name="cmd" value="_s-xclick">
92
96
  <input type="hidden" name="hosted_button_id" value="9ABWULT73Y7AC">
93
97
  <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
94
98
  <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
95
99
  </form>
96
-
100
+ </div>
@@ -37,12 +37,25 @@
37
37
  </div>
38
38
  <%= body %>
39
39
  <p class="coda">
40
- <a href="FIXME email">FIXME full name</a>, <%= modified.pretty %><br>
40
+ <a href="adriano.mitre@gmail.com">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>
44
44
 
45
45
  <!-- insert site tracking codes here, like Google Urchin -->
46
+ <script type="text/javascript">
47
+
48
+ var _gaq = _gaq || [];
49
+ _gaq.push(['_setAccount', 'UA-20605454-1']);
50
+ _gaq.push(['_trackPageview']);
51
+
52
+ (function() {
53
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
54
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
55
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
56
+ })();
57
+
58
+ </script>
46
59
 
47
60
  </body>
48
61
  </html>
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartesian
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 5
9
- - 3
10
- version: 0.5.3
7
+ - 6
8
+ - 0
9
+ version: 0.6.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Adriano Mitre
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-05 00:00:00 -02:00
17
+ date: 2011-01-07 00:00:00 -02:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 47
30
28
  segments:
31
29
  - 2
32
30
  - 8
@@ -133,7 +131,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
131
  requirements:
134
132
  - - ">="
135
133
  - !ruby/object:Gem::Version
136
- hash: 3
137
134
  segments:
138
135
  - 0
139
136
  version: "0"
@@ -142,7 +139,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
139
  requirements:
143
140
  - - ">="
144
141
  - !ruby/object:Gem::Version
145
- hash: 3
146
142
  segments:
147
143
  - 0
148
144
  version: "0"