Skip to content

Commit

Permalink
make sure translate only has one definition -- put-image
Browse files Browse the repository at this point in the history
  • Loading branch information
jpolitz committed Jan 24, 2024
1 parent 99879d9 commit 1701bc6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/web/arr/trove/starter2024.arr
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use context empty-context

import lists as L
import image as I
import image as I
import arrays as A
import option as O
import constants as C
import global as G
import global as G

provide: negate end

provide from L:
all,
Expand Down Expand Up @@ -220,7 +222,6 @@ provide from I:
star-sized,
text,
text-font,
translate,
triangle,
triangle-aas,
triangle-asa,
Expand Down Expand Up @@ -499,3 +500,5 @@ provide from G:
data String,
data Table
end

fun negate(n :: Number) -> Number: n * -1 end
36 changes: 36 additions & 0 deletions test-util/pyret-programs/modules/starter2024-on-essentials.arr
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use context essentials2021

import constants as C

E = C.E
shadow PI = C.PI

sqrt = num-sqrt
expt = num-expt
sqr = num-sqr
abs = num-abs
dilate = scale
shadow translate = put-image
cos = num-cos
sin = num-sin
tan = num-tan
negate = lam(x): -1 * x end

img = text("Joe", 50, "purple")
img2 = rectangle(1000, 200, "outline", "black")

check:
sqrt(1) is 1
expt(2, 3) is 8
sqr(2) is 4
abs(-7) is 7
dilate(2, img) is scale(2, img)
translate(img, 100, 200, img2) is put-image(img, 100, 200, img2)
cos(0) is 1
sin(0) is 0
tan(0) is 0
negate(-8) is 8
cos(PI) is-roughly ~-1
sin(PI / 2) is-roughly ~1
num-exp(1) is-roughly E
end
20 changes: 20 additions & 0 deletions test-util/pyret-programs/modules/starter2024.arr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use context starter2024

img = text("Joe", 50, "purple")
img2 = rectangle(1000, 200, "outline", "black")

check:
sqrt(1) is 1
expt(2, 3) is 8
sqr(2) is 4
abs(-7) is 7
dilate(2, img) is scale(2, img)
translate(img, 100, 200, img2) is put-image(img, 100, 200, img2)
cos(0) is 1
sin(0) is 0
tan(0) is 0
negate(-8) is 8
cos(PI) is-roughly ~-1
sin(PI / 2) is-roughly ~1
num-exp(1) is-roughly E
end

0 comments on commit 1701bc6

Please sign in to comment.