Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

GolfScript many-items rotation

There isn't a builtin in golfscript which lets you rotate a bigger portion of the stack than the three top-most elements.

It should take one number n as argument and rotate the nth value from the top, to the top, so a b c d e f 4 becomes a c d e f b, and it should work regardless of the types of the items.

I came up with this in 27 bytes:

]-1%({1$}4*<@@)>+@@=\~]-1%~

Try it online!

But this is GolfScript, surely it can be done with fewer characters?

Answer*

Draft saved
Draft discarded
Cancel

AltStyle によって変換されたページ (->オリジナル) /