1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

make function arguments immutable by default

This commit is contained in:
Alexander Medvednikov
2019-08-07 08:19:27 +02:00
parent 06b8bd9382
commit 34e0b164eb
22 changed files with 107 additions and 83 deletions

View File

@@ -134,6 +134,7 @@ pub fn exp2(a f64) f64 {
// factorial calculates the factorial of the provided value.
// TODO bring back once multiple value functions are implemented
/*
fn recursive_product( n int, current_number_ptr &int) int{
mut m := n / 2
if (m == 0){
@@ -174,6 +175,7 @@ pub fn factorial(n int) i64 {
}
return i64((r << shift))
}
*/
// floor returns the nearest integer lower or equal of the provided value.
pub fn floor(a f64) f64 {
@@ -191,7 +193,9 @@ pub fn gamma(a f64) f64 {
}
// gcd calculates greatest common (positive) divisor (or zero if a and b are both zero).
pub fn gcd(a, b i64) i64 {
pub fn gcd(a_, b_ i64) i64 {
mut a := a_
mut b := b_
if a < 0 {
a = -a
}

View File

@@ -27,11 +27,13 @@ fn test_digits() {
assert negative_digits[2] == -1
}
/*
fn test_factorial() {
assert math.factorial(12) == 479001600
assert math.factorial(5) == 120
assert math.factorial(0) == 1
}
*/
fn test_erf() {
assert math.erf(0) == 0