Last active
August 29, 2015 14:15
-
-
Save Deco/cbb3b7f4453604c3d6ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MatF[ElementT, PLEASE_HELP] = object | |
data: array[SOME_VARIABLE_LENGTH_HERE, ElementT] | |
template matF*(elementT: typedesc; dimensions: varargs[int]): expr = | |
let dimensionCount = len(dimensions) | |
let elementCount = foldl(dimensions, a*b) | |
??? | |
var a = matF(float64, 4, 4) | |
var b = matF(float64, 4, 4) | |
# The type of `a` and `b` should be something like: | |
# MatF[float64, 2, [4, 4]] | |
# that is: | |
# MatF[element type, dimension count, dimensions] | |
a[1,2] = 44 | |
b[1,2] = 55 | |
var c = a+b | |
echo c[1,2] | |
# operators would be able to accept generic types | |
proc `+`*[A implements MatF, B implements MatF](ma: A, mb: B): ?? = | |
assert that a and b are the same dimensionality and size | |
# how on earth would you even implement this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment