Move vector literals 2 and 3, and add 4-9 + 12 into vector_literals
This commit is contained in:
@@ -13,22 +13,6 @@ fun vector<T>(in:T):vector<T> {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
fun vector<T>(first:T, second:T):vector<T> {
|
|
||||||
var out.construct():vector<T>
|
|
||||||
out.add(first)
|
|
||||||
out.add(second)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
fun vector<T>(first:T, second:T, third:T):vector<T> {
|
|
||||||
var out.construct():vector<T>
|
|
||||||
out.add(first)
|
|
||||||
out.add(second)
|
|
||||||
out.add(third)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
obj vector<T> (Object) {
|
obj vector<T> (Object) {
|
||||||
var data: T*;
|
var data: T*;
|
||||||
var size: int;
|
var size: int;
|
||||||
|
|||||||
104
stdlib/vector_literals.krak
Normal file
104
stdlib/vector_literals.krak
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import vector
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
out.add(fifth)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T, sixth:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
out.add(fifth)
|
||||||
|
out.add(sixth)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T, sixth:T, seventh:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
out.add(fifth)
|
||||||
|
out.add(sixth)
|
||||||
|
out.add(seventh)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T, sixth:T, seventh:T, eighth:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
out.add(fifth)
|
||||||
|
out.add(sixth)
|
||||||
|
out.add(seventh)
|
||||||
|
out.add(eighth)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T, sixth:T, seventh:T, eighth:T, ninth:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
out.add(fifth)
|
||||||
|
out.add(sixth)
|
||||||
|
out.add(seventh)
|
||||||
|
out.add(eighth)
|
||||||
|
out.add(ninth)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T, sixth:T, seventh:T, eighth:T, ninth:T, tenth:T, eleventh:T, twelveth:T):vector::vector<T> {
|
||||||
|
var out.construct():vector::vector<T>
|
||||||
|
out.add(first)
|
||||||
|
out.add(second)
|
||||||
|
out.add(third)
|
||||||
|
out.add(fourth)
|
||||||
|
out.add(fifth)
|
||||||
|
out.add(sixth)
|
||||||
|
out.add(seventh)
|
||||||
|
out.add(eighth)
|
||||||
|
out.add(ninth)
|
||||||
|
out.add(tenth)
|
||||||
|
out.add(eleventh)
|
||||||
|
out.add(twelveth)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
9131321
|
9131321
|
||||||
15513
|
15513
|
||||||
3.7000007.7000007.70000015.700000
|
3.7000007.7000007.70000015.700000
|
||||||
|
123456789101112
|
||||||
Constructed: 0
|
Constructed: 0
|
||||||
Copied: 0 to 1
|
Copied: 0 to 1
|
||||||
Copied: 1 to 2
|
Copied: 1 to 2
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import io:*;
|
import io:*;
|
||||||
import mem:*;
|
import mem:*;
|
||||||
import vector:*;
|
import vector:*;
|
||||||
|
import vector_literals:*
|
||||||
|
|
||||||
obj AbleToBeDestroyed (Object) {
|
obj AbleToBeDestroyed (Object) {
|
||||||
var data:int
|
var data:int
|
||||||
@@ -65,6 +66,9 @@ fun main(): int {
|
|||||||
print(newType.at(i));
|
print(newType.at(i));
|
||||||
println();
|
println();
|
||||||
|
|
||||||
|
vector(1,2,3,4,5,6,7,8,9,10,11,12).for_each(fun(i:int) { print(i); })
|
||||||
|
println()
|
||||||
|
|
||||||
var desVec: vector<AbleToBeDestroyed>* = new<vector<AbleToBeDestroyed>>()->construct();
|
var desVec: vector<AbleToBeDestroyed>* = new<vector<AbleToBeDestroyed>>()->construct();
|
||||||
var testDestruct.construct(0): AbleToBeDestroyed;
|
var testDestruct.construct(0): AbleToBeDestroyed;
|
||||||
desVec->addEnd(testDestruct);
|
desVec->addEnd(testDestruct);
|
||||||
|
|||||||
Reference in New Issue
Block a user