summaryrefslogtreecommitdiff
path: root/src/scenes/lambda_recursion.tsx
blob: 4a2b4a1cc1ac0b4a92278bdc86f4a57fe3222a43 (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
41
42
43
44
45
import { Layout, makeScene2D } from "@motion-canvas/2d";
import {
  Direction,
  beginSlide,
  createRef,
  slideTransition,
} from "@motion-canvas/core";
import { LambdaReducer } from "../components/lambda_reducer";
import { baseDefinitions } from "../utils/lambdas";

export default makeScene2D(function* (view) {
  const lambdaReducer = createRef<LambdaReducer>();
  const layout = createRef<Layout>();

  view.add(
    <Layout
      layout
      ref={layout}
      direction="column"
      alignItems="center"
      gap={50}
    ></Layout>,
  );
  yield* slideTransition(Direction.Right);
  yield* beginSlide("Boolean Reductions");

  for (const term of ["Y", "(Y (λ y . y))"]) {
    yield* layout().opacity(0, 0.5);
    layout().add(
      <LambdaReducer
        ref={lambdaReducer}
        lambdaTerm={term}
        definitions={baseDefinitions}
      ></LambdaReducer>,
    );
    yield* layout().opacity(1, 0.5);

    yield* beginSlide("Next Reduction " + term);
    for (let i = 0; i < 6; i++) {
      yield* lambdaReducer().step(0.5);
      yield* beginSlide(term + " Next Step " + i);
    }
    layout().removeChildren();
  }
});