Flurry
Flurry is a strictly evaluated functional programming language created by User:Challenger5 and inspired by Brain-Flak.
Definition
The main difference from Brain-Flak is that there is only one stack, which contains only functions. Functions are allowed to modify the stack, but are otherwise pure.
All nilads and monads return functions. Rather than denoting integer addition, juxtaposition denotes function application.
Nilads take no arguments and return a function. There are four of them:
[]
evaluates to the height of the stack as a Church numeral.()
evaluates to theK
combinator.<>
evaluates to theS
combinator.{}
evaluates to a value popped off the stack or to theI
combinator if the stack is empty.
Monads enclose one or more operations (nilads or monads) and return a function. There are four of them:
[abc]
reducesabc
by function application and then returns the result. It essentially serves as a grouping operator like parentheses.(abc)
reducesabc
by function application, and then pushes the result to the stack, returning it.<abc>
reducesabc
by function composition and then returns the result.{abc}
returns a function that:- Takes a single argument and pushes that argument to the stack.
- Reduces
abc
by function application. - Returns the result.
The program is a list of zero or more nilads and monads. The initial stack content is the Church-encoded representation of the input.
Snippets
Return the I
combinator:
<>()()
Duplicate the top value on the stack and return it:
(({}))
Return the iota combinator (\x. x S K
):
{{}<>()}
Return the successor function for Church numerals (\a b c. b (a b c)
):
<><<>()>
Pop two Church numerals and return their sum (wrap in {{}}
and it becomes a function of two arguments):
{}[<><<>()>]{}
Pop two Church numerals and return their product (or use <<>()>
for a function of two arguments):
<{}{}>
I believe there is a way to swap the top two stack elements. However, I have devoted some time to the problem and was unable to create one. The reader is encouraged to try this for themselves.
Computational Class
Flurry is probably Turing-complete, but this has yet to be rigorously proven.