Esolanging Fruit

 Flurry

Discussion about golfing in Flurry github.com/Reconcyl/flurry,...
Oct 31, 2020 04:10
antifreeze
Oct 20, 2020 06:30
antifreeze
Oct 7, 2020 22:18
Does anyone really want that?
Oct 7, 2020 22:18
I'm considering adding an interactive IO option where the stack is initialized with two impure functions: one that takes a Church numeral and writes it to STDOUT, and one that ignores its argument and returns a Church numeral read from STDIN.
Oct 5, 2020 18:34
I didn't know we had a page.
Oct 5, 2020 07:39
For example, with P = S S K you can implement factorial along the lines of P (λn s. if n = 0 then 1 else P s (n - 1))
Oct 5, 2020 07:36
In practice, if you want to write a recursive function S S K = λa b. a b a might be a more useful combinator than fix.
Oct 5, 2020 07:19
where fⁿ represents function iteration
Oct 5, 2020 07:18
and more generally, succⁿ K = λf x. fⁿ f
Oct 5, 2020 07:18
succ K = (λn f x. f (n f x)) K
       = λf x. f (K f x)
       = λf x. f f
       = λf x. f f

succ (succ K) = (λn f x. f (n f x)) (λf x. f f)
              = λf x. f ((λf x. f f) f x)
              = λf x. f (f f)
Oct 5, 2020 07:17
Noticing <><<>()> in the expression prompted me to try a few iterates of succ at K:
Oct 5, 2020 07:02
fix = λf. (λx. f (D x x)) (λx. f (D x x))
    = λf. push (λx. f (D x x)) pop
    = λf. push (f ∘ λx. D x x) pop
    = λf. push (f ∘ λx. S (S (K x) (K x))) pop
    = λf. push (f ∘ S ∘ λx. S (K x) (K x)) pop
    = λf. push (f ∘ S ∘ λx. (S ∘ K) x (K x)) pop
    = λf. push (f ∘ S ∘ S (S ∘ K) K) pop
   := {(<{}<>[<><<>()>()]>){}}
Oct 5, 2020 07:02
That gives us a much shorter derivation:
Oct 5, 2020 06:51
D f a = S (S (K f) (K a)) I
     := <> <f [() a]> {{}}
Oct 5, 2020 06:51
Actually, there's an alternative derivation of D for when f and a are already known:
Oct 5, 2020 06:42
(haven't tested if it works, but it should in principle)
Oct 5, 2020 06:41
fix = λf. (λx. x x) (λx. f (D x x))
    = (λx. x x) ∘ (λf x. f (D x x))
    = (λx. x x) ∘ (λf. f ∘ (λx. D x x))
    = S I I ∘ (λf. f ∘ S D I)
   := <[<>{{}}{{}}]{<{}[<>{<><<>[<>[(){}]]()>[(){{}}]}{{}}]>}>
Oct 5, 2020 06:41
You can use the delayed application combinator to implement a Y combinator:
Sep 26, 2020 05:20
It's not Flurry, but I thought I'd revive Flobnar
Sep 24, 2020 04:25
Also {<><<>[<>[(){}]]()>[<>()]}, which has the side effect of evaluating a b.
Sep 24, 2020 04:25
I got {<><<>[<>[(){}]]()>[(){{}}]} after messing around for a bit, but there might be a shorter answer.
Sep 24, 2020 04:03
Challenge: implement the function D = λf a b. f a b. Ensure that D f a does not evaluate f a immediately.
Sep 23, 2020 23:17
It also has the advantage of working when the stack is non-empty, although that doesn't matter in this case.
Sep 23, 2020 23:15
The function is allowed to have side effects as long as it leaves an empty stack empty.
Sep 23, 2020 23:14
The Haskell interpreter works by passing an opaque f and z value and checking that the resulting evaluation chain looks like f (f (... (f z)...))
Sep 23, 2020 23:09
Output.
Sep 23, 2020 23:07
It doesn't look like the online interpreter handles newlines correctly.
Sep 22, 2020 15:22
Already having experience with lambda calculus/CL programming is useful.
Aug 27, 2020 00:51
You can't detect any if they are created during reduction, but you could probably recognize constants and do simple pattern matching for succ, addition, multiplication, and exponentiation.
Aug 27, 2020 00:50
I wonder if it would be possible to add explicit support for Church numerals.
Aug 22, 2020 02:43
I got lucky with that one - it essentially only works due to insane coincidences.
Aug 22, 2020 02:39
Here's a much shorter equality answer (though not composable)
Aug 21, 2020 22:28
That gets us a shorter even/odd answer.
Aug 21, 2020 22:12
Never mind, n(){{}} works.
Aug 21, 2020 22:11
What's the easiest way to convert n from 0 to 1 and vice versa? n[()[<>()]]{{}} is annoyingly long.
Aug 19, 2020 00:28
I guess that's one weird rule you wouldn't have to handle if you wanted a visual interpreter with step-by-step reduction.
Aug 19, 2020 00:23
I forgot how my own interpreter works ಠ_ಠ
Aug 19, 2020 00:23
Ah, never mind
Aug 19, 2020 00:15
In the second example, the first pop returns 3 and the second returns 2.
Aug 19, 2020 00:06
Which means [[f a] b] can have different behavior from [f a b] in some situations.
Aug 19, 2020 00:05
Yes, Flurry reduces a sequence of applications by first reducing each of the terms and then performing each application in sequence.
Aug 18, 2020 22:09
<> <<> () <> [<> {{}}] ()> [() ()] {} {} {{<> ()}}      | a b
<> <<> () <> [<> {{}}] ()> [() ()] b {} {{<> ()}}       | a
<> <<> () <> [<> {{}}] ()> [() ()] b a {{<> ()}}        |
<<> () <> [<> {{}}] ()> b [() () b] a {{<> ()}}         |
<<> () <> [<> {{}}]> [() b] [() () b] a {{<> ()}}       |
<<> () <>> [<> {{}} [() b]] [() () b] a {{<> ()}}       |
<<> ()> [<> [<> {{}} [() b]]] [() () b] a {{<> ()}}     |
<> [() [<> [<> {{}} [() b]]]] [() () b] a {{<> ()}}     |
() [<> [<> {{}} [() b]]] a [() () b a] {{<> ()}}        |
Aug 18, 2020 22:09
Here's the execution trace for your swap operator:
Aug 14, 2020 23:24
The original purpose was to find a shorter SWAP operation, but it didn't end up helping. It might be useful for other people, though
Aug 14, 2020 23:23
I wrote a program to brute force CL expressions a while back: gist.github.com/Reconcyl/2c37c6e52564013bc86f0792df7b5bb6
Aug 14, 2020 06:01
Which argument order would you prefer - Z = λzs. z; S n = λzs. s n or Z = λsz. z; S n = λsz. s n?
Aug 14, 2020 05:59
I might also add support for Scott encoding, though it's a little trickier to detect.
Aug 14, 2020 05:58
I don't know of any.