First run at a dead-simple map library. Writing this has reminded me of the need for a []= operator as well as automatic generation of functions for objects, which really should also include ==
This commit is contained in:
7
tests/test_map.expected_results
Normal file
7
tests/test_map.expected_results
Normal file
@@ -0,0 +1,7 @@
|
||||
3
|
||||
2
|
||||
1
|
||||
3
|
||||
20
|
||||
2
|
||||
4
|
||||
18
tests/test_map.krak
Normal file
18
tests/test_map.krak
Normal file
@@ -0,0 +1,18 @@
|
||||
import io:*
|
||||
import map:*
|
||||
|
||||
fun main():int {
|
||||
var m = map(3,1)
|
||||
m.set(2,2)
|
||||
m.set(1,3)
|
||||
println(m[1])
|
||||
println(m[2])
|
||||
println(m[3])
|
||||
m.set(3,4)
|
||||
m.set(4,20)
|
||||
println(m[1])
|
||||
println(m[4])
|
||||
println(m[2])
|
||||
println(m[3])
|
||||
return 0
|
||||
}
|
||||
@@ -21,5 +21,9 @@ middle: 23
|
||||
all but first: 234
|
||||
all but last: 123
|
||||
just some: 2
|
||||
find test
|
||||
0
|
||||
1
|
||||
2
|
||||
done
|
||||
Destroyed: 0
|
||||
|
||||
@@ -105,6 +105,12 @@ fun main(): int {
|
||||
sliceTest.slice(1,2).do(fun(it:int):void print(it);)
|
||||
println()
|
||||
|
||||
println("find test")
|
||||
var multipleFindTest = vector(1,2,3)
|
||||
println(multipleFindTest.find_index(1))
|
||||
println(multipleFindTest.find_index(2))
|
||||
println(multipleFindTest.find_index(3))
|
||||
|
||||
println("done")
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user