Permutations: Difference between revisions

Content added Content deleted
Line 3,483: Line 3,483:


=={{header|Julia}}==
=={{header|Julia}}==
Julia has support for permutation creation and processing via the <tt>Combinatorics</tt> package. <tt>permutations(v)</tt> creates an iterator over all permutations of <tt>v</tt>.
Julia has support for permutation creation and processing via the <tt>Combinatorics</tt> package. <tt>permutations(v)</tt> creates an iterator over all permutations of <tt>v</tt>. Julia 0.7 and 1.0+ require the line global i inside the for to update the i variable.
<lang Julia>
<lang Julia>
using Combinatorics
using Combinatorics
Line 3,492: Line 3,492:
print("All the permutations of ", term, " (", pcnt, "):\n ")
print("All the permutations of ", term, " (", pcnt, "):\n ")
for p in permutations(split(term, ""))
for p in permutations(split(term, ""))
global i
print(join(p), " ")
print(join(p), " ")
i += 1
i += 1