Skip to content

Instantly share code, notes, and snippets.

View Luna-Klatzer's full-sized avatar
🏳️‍⚧️
Cherish growth ~ she/her

Luna Luna-Klatzer

🏳️‍⚧️
Cherish growth ~ she/her
View GitHub Profile
@Luna-Klatzer
Luna-Klatzer / add.kip
Last active June 26, 2023 14:01
Simple Kipper program to add numbers
def add(firstNum: num, secondNum: num) -> num {
return firstNum + secondNum;
}
var result: num = add(1, 2);
print(result as str);
@Luna-Klatzer
Luna-Klatzer / pow.kip
Created June 26, 2023 13:59
Simple Kipper program to calculate the power-to of two numbers
def pow(base: num, powerTo: num) -> num {
return base ** powerTo;
}
var result: num = pow(2, 8); // -> 256
print(result as str);
@Luna-Klatzer
Luna-Klatzer / prime-factors.kip
Last active February 10, 2024 13:21
Simple Kipper program to get the prime factors of a number
def primeFactors(n: num) -> void {
while (n % 2 == 0) {
print("2");
n /= 2;
}
// For all non-even divisors
for (var i: num = 3; i * i <= n; i += 2) {
while (n % i == 0) {
print(f"{i}");
@Luna-Klatzer
Luna-Klatzer / is-prime.kip
Last active September 9, 2024 12:02
Simple Kipper program to check if a number is prime
def isPrime(n: num) -> bool {
if (n <= 1) {
return false; // Never a prime
} else if (n == 2 || n == 3) {
return true; // Base primes
} else if (n % 2 == 0 || n % 3 == 0) {
return false; // Easy base prime checks
}
for (var i: num = 5; i * i <= n; i += 6) {
@Luna-Klatzer
Luna-Klatzer / kipper-scheme-typing.ts
Created October 22, 2023 14:59
An attempt at developing a type that can infer the correct keys/value types for an interface based on a given schema.
/**
* The validation scheme for an option that is an object.
* @since 0.11.0
*/
export type KipperConfigObjectValidatorScheme = {
[key: string]: "string" | "boolean" | "array<string>" | KipperConfigObjectValidatorScheme;
}
/**
* The validation scheme for the Kipper config.