home *** CD-ROM | disk | FTP | other *** search
- ############################################################################
- #
- # File: lpermute.icn
- #
- # Subject: Procedure to permute elements in a list
- #
- # Author: Ralph E. Griswold
- #
- # Date: September 8, 1992
- #
- ###########################################################################
- #
- # This procedure generates the permutations of elements in a list.
- #
- ############################################################################
-
- procedure lpermute(L)
- local i
-
- if *L = 0 then return []
- suspend [L[i := 1 to *L]] ||| lpermute(L[1:i] ||| L[i+1:0])
- end
-