-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile.tina
67 lines (48 loc) · 1.16 KB
/
file.tina
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
63
64
65
66
67
datatype Name = Ogaga | Afoke | Fejiro (Float) | Yoma (Int, String) | Vovwero (Int, Int)
claim o Name
def o = Ogaga
claim y Name
def y = Yoma (10, "ooo")
claim v Name
def v = Vovwero (23, 2)
-- these are github pilot auto generated lol
claim ebresafe (Name, Name, Name)
def ebresafe = (o, y, v)
-- i defined this
datatype expr =
{ claim name String,
claim age Int,
claim class Int }
-- function to get the class from an expr
claim class (expr -> Int)
def class (e) = case (e) {
expr -> e.class,
_ -> 0
}
-- function to decide if a name if Ogaga
claim og (String -> Int)
def og (n) = case (n) {
"ogaga" -> 1,
_ -> 0
}
-- function to sum two values from a pair
claim sum ((Int, Int) -> Int)
def sum (p) = case (p) {
(a, b) -> a + b,
_ -> 0
}
-- function to calculate fibonacci
claim fib (Int -> Int)
def fib (n) = case (n) {
0 -> 0,
1 -> 1,
_ -> fib (n - 1) + fib (n - 2)
}
fib (10)
-- function to calculte factorial
claim fact (Int -> Int)
def fact (n) = case (n) {
0 -> 1,
_ -> n * fact (n - 1)
}
-- function to get the k-means from a vector as input