home *** CD-ROM | disk | FTP | other *** search
- ############################################################################
- #
- # File: lcomb.icn
- #
- # Subject: Procedure to generate lists of combinations
- #
- # Author: Ralph E. Griswold
- #
- # Date: September 8, 1992
- #
- ###########################################################################
- #
- # This procedure generates the combinations of items in a list.
- #
- ############################################################################
-
- procedure lcomb(L,i)
- local j
-
- if i < 1 then fail
- suspend if i = 1 then [!L]
- else [L[j := 1 to *L - i + 1]] ||| lcomb(L[j + 1:0],i - 1)
- end
-