mirror of
https://github.com/fluencelabs/aqua-lib
synced 2024-12-04 23:30:22 +00:00
Add math.aqua (#21)
This commit is contained in:
parent
df80149d05
commit
8820344f60
2
.github/workflows/check.yml
vendored
2
.github/workflows/check.yml
vendored
@ -31,4 +31,4 @@ jobs:
|
||||
run: npm install -g @fluencelabs/aqua
|
||||
|
||||
- name: Check compilation
|
||||
run: aqua -i . -o /tmp
|
||||
run: aqua -i . --dry
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
||||
run: npm install -g @fluencelabs/aqua
|
||||
|
||||
- name: Check compilation
|
||||
run: aqua -i . -o /tmp
|
||||
run: aqua -i . --dry
|
||||
|
||||
### Publish to NPM registry
|
||||
- uses: actions/setup-node@v1
|
||||
|
46
math.aqua
Normal file
46
math.aqua
Normal file
@ -0,0 +1,46 @@
|
||||
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
|
@ -3,7 +3,8 @@
|
||||
"version": "0.1.1",
|
||||
"description": "Aqua standard library",
|
||||
"files": [
|
||||
"builtin.aqua"
|
||||
"builtin.aqua",
|
||||
"math.aqua"
|
||||
],
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
|
Loading…
Reference in New Issue
Block a user