Add set index in list, and update lib+examples+tests

This commit is contained in:
Neemek 2026-08-20 13:44:10 +02:00
parent 8d12c0bdf8
commit 0f905a7fea
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
12 changed files with 117 additions and 60 deletions

View file

@ -1,5 +1,5 @@
fn<T, R> ([T]) map(f: fn(T) -> R) -> [R] {
fn map<T, R>(list: [T], f: fn(T) -> R) -> [R] {
out := []
for v in list.iter() {

View file

@ -249,3 +249,5 @@ fn tan(x: float) -> float {
# todo
0.0
}
(E:, PI:, sqrt:, log:, ln:, exp:, pow:)

View file

@ -1,25 +1,25 @@
NAMESPACE := ""
func namespace(name: string, test: func()) {
fn namespace(name: str, test: fn()) {
NAMESPACE = name
test()
}
func assertEqual(a: any, b: any) {
fn eq<T>(a: T, b: T) {
if a != b {
write(format("assertion error: % should (but doesn't) equal %", [a, b]))
println(format("assertion error: % should (but doesn't) equal %", [a, b]))
exit(1)
} else if env("DEBUG") != "" {
write(format("assertion success: % equals %", [a, b]))
println(format("assertion success: % equals %", [a, b]))
}
}
func assertNotEqual(a: any, b: any) {
fn neq<T>(a: T, b: T) {
if a == b {
write(format("assertion error: % shouldn't (but does) equal %", [a, b]))
println(format("assertion error: % shouldn't (but does) equal %", [a, b]))
exit(1)
} else if env("DEBUG") != "" {
write(format("assertion success: % doesn't equal %", [a, b]))
println(format("assertion success: % doesn't equal %", [a, b]))
}
}