Add set index in list, and update lib+examples+tests
This commit is contained in:
parent
8d12c0bdf8
commit
0f905a7fea
12 changed files with 117 additions and 60 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -249,3 +249,5 @@ fn tan(x: float) -> float {
|
|||
# todo
|
||||
0.0
|
||||
}
|
||||
|
||||
(E:, PI:, sqrt:, log:, ln:, exp:, pow:)
|
||||
|
|
|
|||
|
|
@ -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]))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue