aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-10-14 12:59:00 -0400
committerAnthony Wang2022-10-14 12:59:00 -0400
commit00f753eb81d9326b0eb6f8d9f344216de3582439 (patch)
treed418b04b5c5618de0317ad412c4eb19333db312b
parentaed3c9a5476a569ff3bd4e99ec3450dfebfd9849 (diff)
Write README
-rw-r--r--README.md39
-rw-r--r--nand.f1
-rw-r--r--test.f4
3 files changed, 40 insertions, 4 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..45d0fc6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,39 @@
+# Flip
+
+Flip is a single-instruction Turing-complete programming language.
+
+Let me break that down for you:
+
+- Turing-complete means that Flip can do basically anything given enough time and memory. Anything!
+
+- Single-instruction means that Flip only has one instruction. WTF, one instruction?
+
+Flip uses a single 2-by-infinity array of bits for memory. That's all the memory you get, sorry.
+
+The only instruction is `flip(x, y)` where `x` is 0 or 1 and `y` is an integer. This flips the bit at index `(x, y)` in the array and returns the flipped value. You can nest `flip(x, y)`, but only for the first parameter. So, `flip(flip(flip(a, b), c), d)` is valid while `flip(flip(a, b), flip(c, d))` is not.
+
+You'll probably get tired writing `flip` and parentheses all day, so [unlike in Lisp](https://xkcd.com/297/), you can throw out all the parentheses and `flip` instructions. Thus, Flip programs look like this:
+```
+0 0
+0 1
+0 0 2
+0 2 1 3
+0 3
+```
+
+That means the same thing as
+```
+flip(0, 0)
+flip(0, 1)
+flip(flip(0, 0), 2)
+flip(flip(flip(0, 2), 1), 3)
+flip(0, 3)
+```
+
+We think you'll agree that the first version is way more aesthetically pleasing and forgiving for your pinky finger.
+
+If you haven't figured it out yet, the Flip program above is [NAND](https://en.wikipedia.org/wiki/NAND_logic#Making_other_gates_by_using_NAND_gates)! Currently, the final line outputs 0, but remove either of the first two lines, and the final output becomes 1. This makes Flip (drumroll please)... Turing complete!
+
+Even better, a Flip interpreter can be trivially implemented in your favorite programming language. See [Flipper](flipper.py) for the official reference implementation written in Python.
+
+So if you're ever feeling down about how horrible today's modern programming languages are, try writing some Flip to flip your day around!
diff --git a/nand.f b/nand.f
index 001e629..0ef93f4 100644
--- a/nand.f
+++ b/nand.f
@@ -1,4 +1,5 @@
0 0
+0 1
0 0 2
0 2 1 3
0 3
diff --git a/test.f b/test.f
deleted file mode 100644
index 70dbd19..0000000
--- a/test.f
+++ /dev/null
@@ -1,4 +0,0 @@
-0 0
-0 0
-0 0
-0 0