Permutations: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 4,164:
=={{header|FutureBasic}}==
Here's a sweet
=== With recursion ===
<syntaxhighlight lang="futurebasic">
Line 4,189 ⟶ 4,191:
</syntaxhighlight>
=== With iteration ===
We can also do it by brute force:
<syntaxhighlight lang="futurebasic">
void local fn perm( w as CFStringRef )
Short a, b, c, d
CFStringRef s
for a = 0 to 3 : for b = 0 to 3 : for c = 0 to 3 : for d = 0 to 3
if a != b and a != c and a != d and b != c and b != d and c != d
print mid(w,a,1); mid(w,b,1); mid(w,c,1); mid(w,d,1)
end if
next : next : next : next
end fn
fn perm (@"abel")
handleevents
</syntaxhighlight>
{{out}} The usual.
=={{header|GAP}}==
|