summaryrefslogtreecommitdiff
path: root/src/scenes/church_encoding.tsx
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-02-13 20:00:02 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-02-13 20:00:02 -0700
commit0c476e92e1807928ffb30864126076ef4c6a0821 (patch)
treea4992161ce4b6203edffb5d78533e9c73e61e6f1 /src/scenes/church_encoding.tsx
parent512c245466fad78106a046c1ea6233acdcc3e4de (diff)
downloadcompiling-the-lambda-calculus-main.tar.gz
compiling-the-lambda-calculus-main.zip
add all the stuffHEADmain
Diffstat (limited to 'src/scenes/church_encoding.tsx')
-rw-r--r--src/scenes/church_encoding.tsx41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/scenes/church_encoding.tsx b/src/scenes/church_encoding.tsx
new file mode 100644
index 0000000..70bafe4
--- /dev/null
+++ b/src/scenes/church_encoding.tsx
@@ -0,0 +1,41 @@
+import { Layout, Txt, makeScene2D } from "@motion-canvas/2d";
+import {
+ Direction,
+ beginSlide,
+ createRef,
+ slideTransition,
+} from "@motion-canvas/core";
+import { theme } from "../theme";
+
+const churchNumerals = [
+ "0 = λ f . λ x . x (no application of f)",
+ "1 = λ f . λ x . f x (one application of f)",
+ "2 = λ f . λ x . f (f x) (two applications of f)",
+ "succ = λ n . λ f . λ x . f ((n f) x)",
+];
+
+export default makeScene2D(function* (view) {
+ const numerals = createRef<Txt>();
+
+ view.add(
+ <Layout layout direction="column" alignItems="center">
+ <Txt fontSize={40} fontFamily={theme.font} fill={theme.text.hex}>
+ Church Encoding
+ </Txt>
+ <Txt
+ ref={numerals}
+ fontSize={30}
+ fontFamily={theme.font}
+ fill={theme.text.hex}
+ ></Txt>
+ </Layout>
+ );
+
+ yield* slideTransition(Direction.Right);
+ yield* beginSlide("The Lambda Calculus - Church Encoding");
+
+ for (const numeral of churchNumerals) {
+ yield* numerals().text(numerals().text() + "\n\n" + numeral, 1);
+ yield* beginSlide("substitution - " + numeral);
+ }
+});