doc/atomic-rdoc/classes/Array.src/M000075.html in facets-0.7.1 vs doc/atomic-rdoc/classes/Array.src/M000075.html in facets-0.7.2
- old
+ new
@@ -3,16 +3,17 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <title>middle (Array)</title>
+ <title>combinations (Array)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/facet/array/middle.rb, line 15</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">middle</span>(<span class="ruby-identifier">offset</span>=<span class="ruby-value">0</span>)
- <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">at</span>( (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">offset</span> )
+ <pre><span class="ruby-comment cmt"># File lib/facet/array/combinations.rb, line 25</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">combinations</span>(<span class="ruby-identifier">head</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rest</span>)
+ <span class="ruby-identifier">crest</span> = <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span>[[]] <span class="ruby-operator">:</span> <span class="ruby-identifier">combinations</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">rest</span>)
+ <span class="ruby-identifier">head</span>.<span class="ruby-identifier">inject</span>([]) { <span class="ruby-operator">|</span><span class="ruby-identifier">combs</span>, <span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-identifier">combs</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">crest</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">comb</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">item</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">comb</span> } }
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
\ No newline at end of file