Category : Miscellaneous Language Source Code
Archive   : PERMUTE1.ZIP
Filename : PERMUTE.SNO
*
* Calling sequence: permute(arg, result)
*
* Arguments (at each level of recursion):
* arg: string to be permuted
* result: used internally to pass intermediate result to next level
* (initially null - omit on initial call)
*
* Local variables (maintained at each level of recursion):
* ch: character of current interest from the argument string
* pre: previous part of original arg string
* post: remaining part of original arg string
define('permute(arg,result)ch,pre,post') :(main)
permute
* Print full result if arg length = 1, and break the recursion
output = eq(size(arg),1) result arg :s(return)
* Otherwise, move through all elements of arg as first element of
* remaining permutation
* Drop to lower level when arg string exhausted
post = arg
loop
post len(1) . ch rem . post :f(return)
* Recursively permute the remaining elements
* Arg passed to next level is current level's original arg,
* less the character of current interest
* Partial result passed to next level is result passed to current
* level, followed by the character of current interest
permute(pre post, result ch)
* Move current character to end of 'pre' string
pre = pre ch :(loop)
* Test the function with keyboard input
main
in = trim(input)
ident(in) :s(end)
permute(in) :(main)
end
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/