Skip to content

Commit e7df5ea

Browse files
committed
update to latest jule version
1 parent ffd6910 commit e7df5ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+353
-356
lines changed

math/abs.jule

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn Abs(mut n: f64): f64 {
2-
if n < 0 {
3-
n = -n
4-
}
5-
ret n
2+
if n < 0 {
3+
n = -n
4+
}
5+
ret n
66
}

math/abs_test.jule

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#build test
22

3-
use testing for std::testing
3+
use "std/testing"
44

55
#test
66
fn testAbs(t: &testing::T) {
7-
t.Assert(Abs(-12.2) == 12.2, "-12.2 should equal to 12.2")
8-
t.Assert(Abs(-12) == 12, "-12 should equal to 12")
9-
t.Assert(Abs(-0.35) == 0.35, "-0.35 should equal to 0.35")
10-
}
7+
t.Assert(Abs(-12.2) == 12.2, "-12.2 should equal to 12.2")
8+
t.Assert(Abs(-12) == 12, "-12 should equal to 12")
9+
t.Assert(Abs(-0.35) == 0.35, "-0.35 should equal to 0.35")
10+
}

math/fact.jule

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn Fact(n: f64): f64 {
2-
if n == 0 {
3-
ret 1
4-
}
5-
ret n * Fact(n - 1)
6-
}
2+
if n == 0 {
3+
ret 1
4+
}
5+
ret n * Fact(n-1)
6+
}

math/fact_test.jule

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#build test
22

3-
use testing for std::testing
3+
use "std/testing"
44

55
#test
66
fn testFact(t: &testing::T) {
7-
t.Assert(Fact(10) == 3628800, "10 fact should equal to 3628800")
8-
}
7+
t.Assert(Fact(10) == 3628800, "10 fact should equal to 3628800")
8+
}

math/fib.jule

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// O(2^n)
22
fn Fib(i: int): int {
3-
if i == 0 || i == 1 {
4-
ret i
5-
}
6-
ret Fib(i - 1) + Fib(i - 2)
3+
if i == 0 || i == 1 {
4+
ret i
5+
}
6+
ret Fib(i-1) + Fib(i-2)
77
}
88

99
// O(n * 2^n)
1010
fn FibSeq(mut n: int): []int {
11-
let mut s: []int
12-
let mut i = n
13-
for i > 0 {
14-
s = append(s, Fib(n - i + 1))
15-
i--
16-
}
17-
ret s
18-
}
11+
let mut s: []int
12+
let mut i = n
13+
for i > 0 {
14+
s = append(s, Fib(n-i+1))
15+
i--
16+
}
17+
ret s
18+
}

math/fib_test.jule

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#build test
22

3-
use testing for std::testing
4-
use slices for std::slices
3+
use "std/slices"
4+
use "std/testing"
55

66
#test
77
fn testFib(t: &testing::T) {
8-
t.Assert(Fib(6) == 8, "index 6 of fib. should be 8")
9-
t.Assert(slices::Equal(FibSeq(6), [1, 1, 2, 3, 5, 8]), "a fib. sequence up to index 6 should be 1, 1, 2, 3, 5, 8")
8+
t.Assert(Fib(6) == 8, "index 6 of fib. should be 8")
9+
t.Assert(slices::Equal(FibSeq(6), [1, 1, 2, 3, 5, 8]), "a fib. sequence up to index 6 should be 1, 1, 2, 3, 5, 8")
1010
}

math/max.jule

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
fn Max(values: ...int): int {
2-
if len(values) == 0 {
3-
ret 0
4-
}
5-
let mut max = values[0]
6-
for _, x in values[1:] {
7-
if max < x {
8-
max = x
9-
}
10-
}
11-
ret max
12-
}
2+
if len(values) == 0 {
3+
ret 0
4+
}
5+
let mut max = values[0]
6+
for _, x in values[1:] {
7+
if max < x {
8+
max = x
9+
}
10+
}
11+
ret max
12+
}

math/max_test.jule

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#build test
22

3-
use testing for std::testing
3+
use "std/testing"
44

55
#test
66
fn testMax(t: &testing::T) {
7-
t.Assert(Max(0, -9024, 1, 894, -34) == 894, "max value should be 894")
7+
t.Assert(Max(0, -9024, 1, 894, -34) == 894, "max value should be 894")
88
}

math/median.jule

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use sort
1+
use "sort"
22

33
fn Median(mut slice: []int): f64 {
4-
slice = sort::QuickSort(slice)
5-
let l = len(slice)
6-
match {
7-
| l == 0:
8-
ret 0
9-
| l%2 == 0:
10-
ret f64(slice[l/2-1] + slice[l/2]) / 2
11-
|:
12-
ret f64(slice[l/2])
13-
}
4+
slice = sort::QuickSort(slice)
5+
let l = len(slice)
6+
match {
7+
| l == 0:
8+
ret 0
9+
| l%2 == 0:
10+
ret f64(slice[l/2-1]+slice[l/2]) / 2
11+
|:
12+
ret f64(slice[l/2])
13+
}
1414
}

math/median_test.jule

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#build test
22

3-
use testing for std::testing
3+
use "std/testing"
44

55
#test
66
fn testMedian(t: &testing::T) {
7-
t.Assert(Median([2, 5, 2, 6, -4, -15, 1, -3]) == 1.5, "median should be 1.5")
8-
}
7+
t.Assert(Median([2, 5, 2, 6, -4, -15, 1, -3]) == 1.5, "median should be 1.5")
8+
}

0 commit comments

Comments
 (0)