summaryrefslogtreecommitdiff
path: root/src/scenes/the_lambda_calculus.tsx
blob: 7a3e6925160fecde3c4ef064994a15f356637626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Layout, Txt, makeScene2D } from "@motion-canvas/2d";
import {
  Direction,
  beginSlide,
  createRef,
  slideTransition,
} from "@motion-canvas/core";
import { theme } from "../theme";

const lambdaRules = [
  '1. "x": A variable is a character or string representing a parameter, and is a valid lambda term.',
  '2. "(λ x . t)" is an "abstraction" - a function definition, taking as input the \nbound variable x and returning the lambda term t.',
  '3. (M N) is an "application", applying a lambda term M with a lambda term N.',
];

export default makeScene2D(function* (view) {
  const rules = createRef<Txt>();

  view.add(
    <Layout layout direction="column" alignItems="center">
      <Txt fontSize={40} fontFamily={theme.font} fill={theme.text.hex}>
        The Lambda Calculus
      </Txt>
      <Txt
        ref={rules}
        fontSize={30}
        fontFamily={theme.font}
        fill={theme.text.hex}
      ></Txt>
    </Layout>
  );

  yield* slideTransition(Direction.Right);
  yield* beginSlide("The Lambda Calculus");

  for (const rule of lambdaRules) {
    yield* rules().text(rules().text() + "\n\n" + rule, 1);
    yield* beginSlide("rule - " + rule);
  }
});