-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.bscr
39 lines (37 loc) · 1.09 KB
/
test.bscr
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
import {mult, div} from Arith;
import Funcs;
type sq` = Square;
n = 9+10*2;
name = "Am" & "ee" & "r";
x = (if n > 2 then 1 else 4)+4;
f x y = if y = null then x else x & y;
fac = \n -> if n < 2 then 1 else n*fac(n-1);
access = \{x: obj} -> do
n = @obj.y.0;
n^ = n^+1;
n^ = n^ * 2;
fib (n^+5);
end where fib n = if n < 3 then 1 else fib(n-1) + fib(n-2) end;
println (f "My name is " name);
f "a" null;
println (fac 10);
textC = class str so
text = @str;
end;
objC = class n with textC::textC.new "Hello" so
x = n;
getX self n = self:id (self.x.y.0 + n);
id self x = x;
static fromNothing _ = objC.new {y: (1, 2)};
static fromNumber x y = objC.new {y: (x, y)};
end;
obj = objC.fromNumber 4 "ABC";
println (access {obj with s: "h", m: 3});
access {x: {y: (4, 7, "XYZ"), text: "No!"}} + 4;
area shape =
match shape with
| sq` {n: n} -> Arith->mult n n
| Circle cir -> 3.14 .* cir.r .* cir.r
end;
println (area (sq` {obj with n: n}));
let double n = mult n 2 in println (obj:getX (double ((Funcs->apply (Funcs->flip div 4) Arith->arrow))))