RosettaCodeData/Task/Combinations/M2000-Interpreter/combinations-1.m2000

33 lines
943 B
Plaintext

Module Checkit {
Function Combinations (m as long, n as long){
Global a$
Document a$
Module Level (n, s, h) {
If n=1 then
while Len(s)
a$<=h#str$("-")+"-"+car(s)#str$()+{
}
s=cdr(s)
End While
Else
While len(s)
call Level n-1, cdr(s), cons(h, car(s))
s=cdr(s)
End While
End if
}
If m<1 or n<1 then Error
s=(,)
for i=0 to n-1
Append s, (i,)
next
s=s#sort()
Head=(,)
Call Level m, s, Head
=a$
}
ClipBoard Combinations( 3, 5)
report clipboard$
}
Checkit