home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / BIPL.ZIP / PROCS.ZIP / LPERMUTE.ICN < prev    next >
Encoding:
Text File  |  1992-09-28  |  601 b   |  23 lines

  1. ############################################################################
  2. #
  3. #    File:     lpermute.icn
  4. #
  5. #    Subject:  Procedure to permute elements in a list
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     September 8, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  This procedure generates the permutations of elements in a list.
  14. #
  15. ############################################################################
  16.  
  17. procedure lpermute(L)
  18.    local i
  19.  
  20.    if *L = 0 then return []
  21.    suspend [L[i := 1 to *L]] ||| lpermute(L[1:i] ||| L[i+1:0])
  22. end
  23.