-
Notifications
You must be signed in to change notification settings - Fork 6
/
math.aqua
48 lines (44 loc) · 1.28 KB
/
math.aqua
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
48
aqua MathLib declares *
service Math("math"):
-- x + y
add(x: i64, y: i64) -> i64
-- x - y
sub(x: i64, y: i64) -> i64
-- x * y
mul(x: i64, y: i64) -> i64
-- floor(x * y)
fmul(x: f64, y: f64) -> i64
-- x / y
div(x: i64, y: i64) -> i64
-- division remainder, x % y
rem(x: i64, y: i64) -> i64
-- x^y
pow(x: i64, y: u32) -> i64
-- logarithm of y to base x
-- x – logarithm base
log(x: i64, y: i64) -> u32
service Compare("cmp"):
-- x > y
gt(x: i64, y: i64) -> bool
-- x >= y
gte(x: i64, y: i64) -> bool
-- x < y
lt(x: i64, y: i64) -> bool
-- x <= y
lte(x: i64, y: i64) -> bool
-- compare x and y
-- x < y, return -1
-- x = y, return 0
-- x > y, return 1
cmp(x: i64, y: i64) -> i8
service Array("array"):
-- sum of all numbers in array
sum(xs: []i64) -> i64
-- remove duplicates, not stable
dedup(xs: []string) -> []string
-- set-intersection of two arrays, not stable, deduplicates
intersect(xs: []string, ys: []string) -> []string
-- set-difference of two arrays, not stable, deduplicates
diff(xs: []string, ys: []string) -> []string
-- symmetric difference of two arrays, not stable, deduplicates
sdiff(xs: []string, ys: []string) -> []string