Basic support for templates in ast, rest will come with types

This commit is contained in:
Nathan Braswell
2018-06-22 09:02:30 -04:00
parent a8d4b4eb7f
commit 6ffe7aee46
5 changed files with 130 additions and 20 deletions

View File

@@ -289,12 +289,24 @@ obj vec<T> (Object, Serializable) {
newVec.addEnd(func(data[i]))
return newVec
}
fun map<U>(func: run(ref T):U):vec<U> {
var newVec.construct(size): vec<U>
for (var i = 0; i < size; i++;)
newVec.addEnd(func(data[i]))
return newVec
}
fun map<U>(func: fun(T):U):vec<U> {
var newVec.construct(size): vec<U>
for (var i = 0; i < size; i++;)
newVec.addEnd(func(data[i]))
return newVec
}
fun map<U>(func: run(T):U):vec<U> {
var newVec.construct(size): vec<U>
for (var i = 0; i < size; i++;)
newVec.addEnd(func(data[i]))
return newVec
}
fun flatten_map<U>(func: fun(T):vec<U>):vec<U> {
var newVec.construct(size): vec<U>
for (var i = 0; i < size; i++;) {