Prm: Difference between revisions

From The K Language Wiki
Content added Content deleted
("Add all appropriate categories to each verb")
("Better category ordering, add redirects to categories, fix pseudo-adverb categories")
 
Line 38: Line 38:
</pre>
</pre>


[[Category:Named verbs]]
[[Category:Verbs]]
[[Category:Verbs]]
[[Category:Named verbs]]
[[Category:Primitives]]
[[Category:Primitives]]

Latest revision as of 06:42, 9 July 2022

Prm
prm x
Supported in oK, K7, K9

prm generates all permutations of its input array.

If given a number, generates all permutations of the range !x.

In oK, the permutations are represented by the rows:

 prm "ABC"
("ABC"
 "ACB"
 "BAC"
 "BCA"
 "CAB"
 "CBA")

Shakti(K7) onwards does not accept arrays as an argument, so a construct like {x@prm#x} may be used.

 {x@prm#x}@"ABC"
ABC
BAC
BCA
ACB
CAB
CBA

Shakti(K9) returns the permutations as columns:

 prm 3
0 1 1 0 2 2
1 0 2 2 0 1
2 2 0 1 1 0