forked from hexengraf/lambari
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdlib.falk
More file actions
62 lines (56 loc) · 1017 Bytes
/
stdlib.falk
File metadata and controls
62 lines (56 loc) · 1017 Bytes
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Falk Standard Library v1.0
// Returns the sum of the values of an array
function sum(array x):
var c : typeof x[0]
for (element in x):
c += element
.
return c
.
// Returns the product of the values of an array
function prod(array x):
var c : typeof x[0]
c = 1
for (element in x):
c *= element
.
return c
.
// Returns the factorial of a given number
function fact(var x):
var c = 1
while (x > 0):
c *= x
x -= 1
.
return c
.
// Returns the square root of n
function sqrt(var n):
return n ** 0.5
.
// Returns the size of an array
function array_size(array s):
var size : real
for (e in s):
size += 1
.
return size
.
// Returns the number of lines of a matrix
function num_lines(matrix m):
var count = 0;
for (row in m):
count += 1;
.
return count;
.
// Returns the number of lines of a matrix
function num_columns(matrix m):
var count = 0;
auto row = m[0];
for (elem in row):
count += 1;
.
return count;
.