From: Todd A. Jacobs on 3 Jun 2010 12:04 Ruby has a terrific implementation of single-valued permutations, but it doesn't yield the results I expected when using arrays of arrays. For example: [[1, 2], [2, 3]].permutation.to_a.include? [2, 1] => false The reason is that there's no permutation of the sub-arrays, just of the top-level array elements. Am I overlooking something obvious here? I'd like the permutations to include randomization within each sub-array, too. -- "Oh, look: rocks!" -- Doctor Who, "Destiny of the Daleks"
From: botp on 3 Jun 2010 12:59 On Fri, Jun 4, 2010 at 12:04 AM, Todd A. Jacobs <tjacobs-sndr-019fdb(a)codegnome.org> wrote: > The reason is that there's no permutation of the sub-arrays, just of the > top-level array elements. you assumed that it has *only* sub-arrays consider eg, [[1, 2], :a, String, 3].permutation.to_a > Am I overlooking something obvious here? I'd > like the permutations to include randomization within each sub-array, just include permutation of the sub then kind regards -botp
|
Pages: 1 Prev: watir 1.6.5, ruby 1.8.7 and character encoding problem Next: Root Module (code) |