Skip to content

Commit

Permalink
populated save slots with teen tylr study examples
Browse files Browse the repository at this point in the history
  • Loading branch information
disconcision committed Nov 5, 2024
1 parent 39bb3b0 commit c8800ba
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 58 deletions.
54 changes: 54 additions & 0 deletions src/web/Data.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
let t0_transcribe = {|let x = 1 in
x + 2|};

let t0_modify = {|let x = 1 in
let y = 2 in
x + y|};

let t1_transcribe = {|fun (center, p) ->
let (x1, y1) = center in
let (x2, y2) = p in
let r = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) in
circle(center, r)|};

let t1_modify = {|let dist =
fun (p1, p2) ->
let (x1, y1) = p1 in
let (x2, y2) = p2 in
sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))
in
fun (center, p) ->
let r = dist(center, p) in
circle(center, r)|};

let t2_transcribe = {|fun (p1, p2) ->
let mark =
fun center ->
let r = 4 in
circle(center, r)
in
[mark(p1), line(p1, p2), mark(p2)]|};

let t2_modify = {|fun (square, p1, p2) ->
let mark =
fun center ->
if square then
let (x, y) = center in
rect(x - 2, y - 2, 4, 4)
else
let r = 4 in
circle(center, r)
in
[mark(p1), line(p1, p2), mark(p2)]|};

let t3_transcribe = {|shapes
|> map(rotate(pi / 4))
|> map(translate(6, 7))
|> filter(fun shape -> area(shape) < 50)
|> map(dilate(5))|};

let t3_modify = {|shapes
|> filter(fun shape -> area(shape) < 50)
|> map(dilate(5))
|> map(rotate(pi / 4))
|> map(translate(6, 7))|};
69 changes: 11 additions & 58 deletions src/web/Store.re
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ let save_syntax = (save_idx: int, z: Zipper.t) =>

let editor_defaults = [
serialize(Zipper.empty),
serialize(parse("2")),
serialize(parse("3 + 3")),
serialize(parse("(4)")),
serialize(parse("(5 + 5) * 5")),
serialize(parse("let x = 6 in x")),
serialize(parse("case 7\n| x => 7")),
serialize(parse("let (a, b) =\n(8*9<6, 17==6) in\n(a,(a, b))")),
serialize(parse("let f = fun z -> 9 in f(9)")),
serialize(parse("0")),
//serialize(parse("let x = 3 in x")),
//serialize(parse("let f = fun x -> 4 in f(4)")),
//serialize(parse("case 5 | x => 5")),
serialize(parse(Data.t0_transcribe)),
serialize(parse(Data.t0_modify)),
serialize(parse(Data.t1_transcribe)),
serialize(parse(Data.t1_modify)),
serialize(parse(Data.t2_transcribe)),
serialize(parse(Data.t2_modify)),
serialize(parse(Data.t3_transcribe)),
serialize(parse(Data.t3_modify)),
// serialize(parse("case 7\n| x => 7")),
// serialize(parse("let (a, b) =\n(8*9<6, 17==6) in\n(a,(a, b))")),
// serialize(parse("let f = fun z -> 9 in f(9)")),
];

let load_default_syntax: int => Zipper.t =
Expand All @@ -56,49 +55,3 @@ let load_syntax: int => Zipper.t =
};

//let unparse: Zipper.t => string = z => z |> Zipper.zip |> Cell.tokens;

let _editor_defaults = [
"",
"",
"fun center, p ->
let x1, y1 = center in
let x2, y2 = p in
let r = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) in
circle(center, r)
",
"",
"shapes
|> map(rotate(pi / 4))
|> map(translate(6, 7))
|> filter(fun shape -> area(shape) < 50)
|> map(dilate(5))
",
"",
"fun square, p1, p2 ->
if square then
let mark =
fun center ->
let x, y = center in
rect(x - 2, y - 2, 4, 4)
in
[mark(p1); line(p1, p2); mark(p2)]
else
let mark =
fun center ->
let r = 4 in
circle(center, 4)
in
[mark(p1); line(p1, p2); mark(p2)]
",
"let ss1 = observe(msg, map_rotate(map_dilate(shapes))) in
let ss2 = map_brighten(shapes) in
[ss1; ss2]
",
"let foo =
fun taz ->
case taz of
| (2, torb) -> bargle + 7*torb
| (blee, 5) -> krunk ? blee : 66
in foo(0!)",
"let foo = fun taz -> (fun bar -> (taz + 2*bar)) in foo(1!)",
];

0 comments on commit c8800ba

Please sign in to comment.