catseye / flobnar Goto Github PK
View Code? Open in Web Editor NEWMIRROR of https://codeberg.org/catseye/Flobnar : This is what happens when you get Befunge-93 drunk
Home Page: https://catseye.tc/node/Flobnar
License: Other
MIRROR of https://codeberg.org/catseye/Flobnar : This is what happens when you get Befunge-93 drunk
Home Page: https://catseye.tc/node/Flobnar
License: Other
This should permit us to add I/O while only making a handful of functions monadic. (Basically the "trampoline" would be monadic and would do I/O on behalf of the continuations it executes.) This seems marginally cleaner than making the entire evaluator monadic. But experiment and see.
The README states without explanation that
| 0
| 5 p <
| 0 +@
| g <
| 0
= Result: 5
and also that
8
*,< 5
9 +@>*
>,*7
3
is supposed to print Hi
, not iH
. In both examples, it seems like the north branch is getting evaluated "before" the south branch, but I don't know if that's meant to be a general rule. (Maybe the right-hand branch is always evaluated before the left-hand branch!)
A more "functional-spirited" rule would be that each branch spawns a completely new copy of funge-space, so that side-effects happening in one branch can never be observed by the other branch, and thus the interpreter could memoize and/or multi-thread any way it wanted. However, this rule clearly conflicts with existing examples such as the p
/g
one above.
If we are indeed guaranteed that the north operand is always evaluated before the south operand, then we can write a "non-explicitly recursive" factorial program like this:
| 0 0
| >g >p:
| * /0# <<< \@
| > v 6
| #0201
| g` |<
| 0>g
| #00
| -p<
| 10+<
| ^ <
= Result: 720
Notice the application of /
as a short-circuiting conditional operator: "evaluate to the north, then, if the condition to the south is true, return the result of the north evaluation; else return the result of evaluating to the east." Here the condition to the south is always 0
, so I'm just using /
as a more compact version of +
that evaluates north-then-east instead of north-then-south.
If you go into this project's settings and mark master
as your GitHub Pages branch, then navigating to https://catseye.github.io/Flobnar/demo/flobnar.html should Just Work, eliminating the need for people to download the HTML demo in order to see it.
Maybe these rules are intentional, but without explicit calling-out in the README, it feels like they might have been oversights (of the kind that reduce fun more than increase it).
The
p
term evaluates to the north to get an x coordinate, then to the south to get a y coordinate. It then evaluates what is on the other side of it to get a value.
Does this imply that
| v<
| #+@
| 1#
| p1
| 6g
| 6
= Result: 6
because the 6
south of the p
is evaluated twice โ once as the y coordinate and then again as the "what is on the other side of" the p
?
Similarly:
The
\
term takes what to the south of it evaluates to, and uses that as the argument as it "applies" the "one-argument" "function" on the other side of it.
| v\@
| \2
| >*
| :
= Result: 8
because the second slash first evaluates "to the south" (2*:
) to get the value 4, and then uses 4 as the argument to the function "on the other side of it" (identically 2*:
) to get 2*4=8.
I'm generally surprised by the fixed cardinal directions in Flobnar, btw. It would feel much more "Befungey" if you had made
| 1+2
| ^@
= Hypothetical Result: 3
(whereas with the fixed north/south rule, my understanding is that this program should produce infinite-recursion-and-crash while trying to evaluate the north operand of +
).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.