Cycles of a permutation: Difference between revisions
Content added Content deleted
(julia example) |
|||
Line 128: | Line 128: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Normally, the Permutations.jl Julia package could be used, but equivalent non-library code is used instead, as specified in the task. |
Normally, the Permutations.jl Julia package could be used, but equivalent non-library code is used instead, as specified in the task. |
||
Note that the Alf and Betty's notation for cycles seems inverted compared to the syntax in Permutations.jl |
Note that the Alf and Betty's notation for cycles seems inverted compared to the syntax in Permutations.jl. Printing of cycles |
||
is therefore customizable in the code to either format, and the code is specified so as to |
is therefore customizable in the code below so as to fit to either format, and the test function's code is specified so as to |
||
the examples given in the task. |
duplicate the cycles as written in examples given in the task. |
||
<lang julia>""" A Perm is a permutation in one-line form. `a` is a shuffled gapless 1-based range of Int. """ |
<lang julia>""" A Perm is a permutation in one-line form. `a` is a shuffled gapless 1-based range of Int. """ |
||
struct Perm |
struct Perm |