Difference between revisions of "Array.cartesianproduct()"
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
3 3 | 3 3 | ||
− | To find all Pythagorean Triplets between 1..10, do: | + | To find all [https://en.wikipedia.org/wiki/Pythagorean_triple Pythagorean Triplets] between 1..10, do: |
[1..10,1..10].cartesianproduct().filter(r=>ISINTEGER(SQRT(SUMSQ(r)))) | [1..10,1..10].cartesianproduct().filter(r=>ISINTEGER(SQRT(SUMSQ(r)))) |
Latest revision as of 11:37, 16 February 2020
Array.cartesianproduct()
Returns cartesian product of each array element in the array.
[1..3,2..3].cartesianproduct()
1 2
1 3
2 2
2 3
3 2
3 3
To find all Pythagorean Triplets between 1..10, do:
[1..10,1..10].cartesianproduct().filter(r=>ISINTEGER(SQRT(SUMSQ(r))))
3
|
4
|
4
|
3
|
6
|
8
|
8
|
6
|