A version that compares every element to the whole list (so far) to filter out
is innefficient even for perm 8
reduce =: 1 : '<"_1@[ ([: u (&.>)/(>@:) ,) <@:]'
(}: (|.@:[ (|.@:[ , ])^:(-.@:e.) ])reduce ,:@:{:)&.|. (i.@!A.i.)4
----- Original Message -----
From: 'Pascal Jasmin' via Programming <[email protected]>
To: Programming Forum <[email protected]>
Cc:
Sent: Friday, August 21, 2015 1:10 PM
Subject: [Jprogramming] permutations without reverses
for 3, removing the "reverse duplicates" of permutations is as easy as taking
the top half
(i.@! A. i.) 3
0 1 2
0 2 1
1 0 2
1 2 0
2 0 1
2 1 0
last (5) is reverse of 0. 4 is reverse of 2, and 3 reverse of 1
Is there a function for producing permutations without their reverse included?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm