changed "get it" link & re-rendered site

1 parent e7497d1 commit b3feb0be58d7eba2767840f12f6df278a38dc8e1 committed Jan 7, 2011
Showing with 132 additions and 6 deletions.
1. +0 −1 .gitignore
2. +127 −2 index.html
3. +4 −2 script/txt2html
4. +1 −1 website/doc/created.rid
 @@ -1,4 +1,3 @@ -older_versions/* coverage/* pkg/* doc/*
 @@ -1,3 +1,128 @@ - - + + + + + + + + + + + + + +
+ +

+
+

Get Version

+ 0.6.0 +
+

cartesian

+

Cartesian products in Ruby

+

What

+

Provides methods for the calculation of the cartesian producted between
+two or more enumerable objects. Includes grid search optimization methods.
+It can also be easily and conveniently mixed-in into any enumerable class.

+

Installing

+

sudo gem install cartesian

+

The basics

+

Cartesian::product [1,2],[3,4] #=> [[1, 3], [1, 4], [2, 3], [2, 4]]

+

Demonstration of usage

+

One can use the Cartesian module directly
+

+require 'cartesian'
+foo = [1, 2]
+bar = ["a", "b"]
+Cartesian::product(foo, bar) #=> [[1, "a"], [1, "b"], [2, "a"], [2, "b"]]
+

+

or use the methods provided by the mixin in the Array class

+

+foo.cartesian(bar)  #=> [[1, "a"], [1, "b"], [2, "a"], [2, "b"]]
+

+

which include the short’n’sweet x method

+

+v = [] #=> []
+for a, b in [1,2].x [3,4]
+  v << [a,b]
+end #=> true
+v #=> [[1, 3], [1, 4], [2, 3], [2, 4]]
+

+

The ‘**’ operator provides a convenient way of iterating multi-dimensionally over the same array or range

+

+u = [0, 1]**3 #=> #<CartesianIterator:0x7f2fb8e54978 @tot_iter=8, \
+  #                @lists=[[0, 1], [0, 1], [0, 1]]>
+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]]
+

+

Finally, the grid search methods

+

+require 'grid_search'
+[-1, 0, 1, 2].argmax {|x| x**2 } #=> 2
+[-1, 0, 1, 2].argmin {|x| x.abs } #=> 0

+

+

For more examples and details, see the RDoc-generated documentation here.

+

How to submit patches

+

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

+

You can fetch the source from:

+ +
+

Build and test instructions

+
cd cartesian
+rake test
+rake install_gem
+

+

This code is free to use under the terms of the MIT license.

+

Contact

+

+
+
+ + + +

+ +
+

+ Adriano Mitre, 7th January 2011
+ Theme extended from Paul Battley +

+
+ + + + +
 @@ -1,7 +1,7 @@ #!/usr/bin/env ruby GEM_NAME = 'cartesian' # what ppl will type to install your gem -RUBYFORGE_PROJECT = 'cartesian' +GITHUB_PROJECT = 'cartesian' require 'rubygems' begin @@ -18,11 +18,13 @@ require 'erb' require File.dirname(File.expand_path(__FILE__)) + "/../lib/#{GEM_NAME}.rb" version = Cartesian::VERSION -download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" +download = "http://github.com/adrianomitre/#{GITHUB_PROJECT}" +=begin def rubyforge_project_id RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT] end +=end class Fixnum def ordinal
 @@ -1,4 +1,4 @@ -Fri, 07 Jan 2011 04:52:32 -0200 +Fri, 07 Jan 2011 05:00:34 -0200 README.rdoc Fri, 07 Jan 2011 02:46:43 -0200 lib/cartesian.rb Fri, 07 Jan 2011 02:46:43 -0200 lib/cartesian_iterator.rb Fri, 07 Jan 2011 02:46:43 -0200