RosettaCodeData/Task/Permutations/Liberty-BASIC/permutations-2.basic

20 lines
340 B
Plaintext

n = 3
s$=""
for i = 1 to n
s$=s$;i
next
res$=permutation$("", s$)
Function permutation$(pre$, post$)
lgth = Len(post$)
If lgth < 2 Then
print pre$;post$
Else
For i = 1 To lgth
tmp$=permutation$(pre$+Mid$(post$,i,1),Left$(post$,i-1)+Right$(post$,lgth-i))
Next i
End If
End Function