-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguageDemo.des
More file actions
47 lines (32 loc) · 967 Bytes
/
Copy pathlanguageDemo.des
File metadata and controls
47 lines (32 loc) · 967 Bytes
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
46
47
Num a = 4
Point b = (5,2)
Bool c = true
Color d = (100,150,200)
Point[] pts = [b,(1,3),(2,2)] // Eventually add higher-dimension lists
Num n = solve(5 = n^2 + 2n - 3) // Does a regression
Num e = 2*a
def Num triple(Num x) = 3*x
def function quadruple(Num y):
Num x = triple(y)
return x+y
def action tripleA():
a := quadruple(a)
draw circle(b)[filled=c]
def shape TriWithCircle(Point p1, Point p2, Point p3):
draw polygon(p1,p2,p3)
Point center = (p1 + p2 + p3)/3
draw circle(center,||p1-center||)
draw TriWithCircle(pts[0],pts[1],pts[2])
def struct Ball(Point center, Num radius):
draw circle(center,radius)
Num diameter = radius*2
def action move(Point displacement):
center += displacement
Ball b1 = {(4,5),a}
Num d1 = b1.diameter
def struct Vec3D(Num x, Num y, Num z):
Num[] coords = [x,y,z]
static:
def constructor (Num[] c) = {c[0],c[1],c[2]}
def operator +(a,b) = {a.coords + b.coords}
def operator ||(x) = {sqrt(x^2+y^2+z^2)}