forked from Nano-Collective/nanocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-file.ts
More file actions
75 lines (62 loc) · 1.54 KB
/
Copy pathtest-file.ts
File metadata and controls
75 lines (62 loc) · 1.54 KB
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
68
69
70
71
72
73
74
75
// A simple file to give to models to test Nanocoder's functionality
/**
* Greets a person by name
* @param name - The name of the person to greet
* @returns A greeting string
*/
export function greet(name: string): string {
return `Hello ${name}!`;
}
/**
* Adds two numbers together
* @param a - The first number
* @param b - The second number
* @returns The sum of a and b
*/
export function add(a: number, b: number): number {
return a + b;
}
/**
* Multiplies two numbers together
* @param x - The first number
* @param y - The second number
* @returns The product of x and y
*/
export function multiply(x: number, y: number): number {
return x * y;
}
// More functions to make a medium-sized file
/**
* Subtracts the second number from the first number
* @param a - The number to subtract from
* @param b - The number to subtract
* @returns The difference of a and b
*/
export function subtract(a: number, b: number): number {
return a - b;
}
export function divide(a: number, b: number): number {
if (b === 0) {
throw new Error("Division by zero");
}
return a / b;
}
export function power(base: number, exponent: number): number {
return Math.pow(base, exponent);
}
export function sqrt(n: number): number {
return Math.sqrt(n);
}
export function abs(n: number): number {
return Math.abs(n);
}
export function round(n: number): number {
return Math.round(n);
}
export function floor(n: number): number {
return Math.floor(n);
}
export function ceil(n: number): number {
return Math.ceil(n);
}
// End of test file