Permutations: Difference between revisions

Content deleted Content added
Petelomax (talk | contribs)
m →‎{{header|Phix}}: use new builtin
Mr Dalien (talk | contribs)
No edit summary
Line 753: Line 753:
(44444, 333, 1, 22)
(44444, 333, 1, 22)
(44444, 333, 22, 1)
(44444, 333, 22, 1)
</pre>

=={{header|Amazing Hopper}}==
{{trans|AWK}}
<lang Amazing Hopper>
/* hopper-JAMBO - a flavour of Amazing Hopper! */

#include <jambo.h>
Main
leng=0
Void(lista)
Set("la realidad","escapa","a los sentidos"), Apnd list(lista)
Length(lista), Move to(leng)
Toksep(" ")
Printnl( lista )
Set(1) Gosub(Permutar)
End-Return

Subrutines

Define( Permutar, pos )
If ( Sub(leng, pos) Isgeq(1) )
i=pos
Loop if( Less( i, leng ) )
Plusone(pos), Gosub(Permutar)
Set( pos ), Gosub(Rotate)
Printnl( lista )
++i
Back
Plusone(pos), Gosub(Permutar)
Set( pos ), Gosub(Rotate)
End If
Return

Define ( Rotate, pos )
c=0, [pos] Get(lista), Move to(c)
[ Plusone(pos): leng ] Cget(lista)
[ pos: Minusone(leng) ] Cput(lista)
Set(c), [ leng ] Cput(lista)
Return
</lang>
{{out}}
<pre>
</pre>
</pre>