FastPermute(3)

πŸ“¦
version 0.999 Β· 2 versions
, in fedora 43

πŸ¦‹ FastPermute(3) β€” like, the whole vibe ✨

okay bestie, so this is a page from the User Contributed Perl Documentation, and it's all about a little module called Algorithm::FastPermute πŸ’– it's giving "my permutations are faster than yours" and honestly? it ate.


🌸 NAME 🌸

Algorithm::FastPermute β€” Rapid generation of permutations πŸ‘‘


✨ SYNOPSIS ✨

use Algorithm::FastPermute ('permute');
my @array = (1..shift());
permute {
    print "@array\n";         # Print all the permutations
} @array;

πŸ’… DESCRIPTION πŸ’…

so here's the tea πŸ«– β€” Algorithm::FastPermute generates all the permutations of an array. You hand it a block of code, and that block gets run once for every single permutation. The array gets changed in place, and then changed back again before permute returns. Iconic behavior, honestly.

but like, while your callback is running, the array is read-only and you'll get an error if you try to change its length 😭 (you can change its elements, but the consequences are liable to confuse you and may change in future versions β€” so, like, don't).

You have to pass an array, bestie. It can't just be a list. It does work with special arrays and tied arrays, though unless you're doing something particularly abstruse you'd be better off copying the elements into a normal array first πŸŽ€

It's very fast. My tests suggest it's four or five times as fast as Algorithm::Permute's traditional interface πŸ”₯ If you're permuting a large list (nine or more elements, say) then you'll appreciate this enormously. If your lists are short then Algorithm::Permute will still finish faster than you can blink, and you may find its interface more convenient. different strokes, no cap πŸ’œ

In fact, the FastPermute interface (and code) is now also included in Algorithm::Permute, so you may not need both πŸ‘€ Enhancements and bug fixes will appear here first, from where (at Edwin Pratomo's discretion) they'll probably make their way into Algorithm::Permute.

okay so this next part is important ⚠️ The code is run inside a pseudo block, rather than as a normal subroutine. That means you can't use return, and you can't jump out of it using goto and so on. Also, caller won't tell you anything helpful from inside the callback. Such is the price of speed πŸ’€

and like, the order in which the permutations are generated is not guaranteed, so don't rely on it. periodt. 🚫

πŸŽ€ EXPORT πŸŽ€

The permute function is exported by default. you don't even have to ask, she just shows up πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Robin Houston, <robin@kitsite.com>

Based on a C program by Matt Day.


🌈 SEE ALSO 🌈

Algorithm::Permute


Copyright (c) 2001-2008, Robin Houston. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. 🫢


and that's the whole page, bestie!! πŸ’– this one came from perl v5.42.0, dated 2025-07-25, and it's the FastPermute(3) page β€” slay, bye, go permute something 🧚✨

πŸ“¦ where this page comes from