Slindow

From Esolang
Jump to navigation Jump to search

Slindow is an esoteric programming language invented by User:A that makes it easy to solve sliding-window challenges. Inspired by this challenge.

Built-ins

Slindow automatically pushes all input as atoms([1 2 3] counts as 1 array atom and 1 counts as 1 integer atom/a length-1 array atom.) The top of the stack is outputted by default.

* Cut the top of the stack to the accumulator.
/ Paste the accumulator's value to the stack.
array: Push the indicated array. If the length is 1, you don't need brackets.
} Start a for loop that iterates the length of the top of the stack times, popping the item.
' Put the top-array's back item to the front.
" Put the top-array's front item to the back.
~ Return the nth prefix of the second top-of-stack; n is the top of the stack.
` Return the nth suffix of the second top-of-stack; n is the top of the stack.
w Return the sliding-windows of the bottom of the second-to-top atom with a width of the top of the stack.
{ Starts a for loop iterating over each item of the top of the stack, popping the item.
. End a loop
m Return the minimum of the current item as an array atom
M Return the maximum of the current item as an array atom
+ Concatenate the top two items into an array
@ Apply the effect onto the whole stack instead
- The difference between the top two items

Sliding-window minimum challenge

*}/~m@'1~-.@+