Replies: 2 comments 2 replies
-
You would have to make an alias for the int slice. type Slice = []int
(a1 Slice) + (a2 Slice) Slice {
result := Slice([]int{len: a1.len, init: 0})
for i in 0 .. a1.len{
result[i] = a1[i] + a2[i]
}
return result
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
neither of the above code snippets works.There is something missing. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am very interested as a scientist to use the V Language because of the simplicity and ease of writing while still generating highly optimizable code that can run on everything through the use of C as an IR.
There is just one thing that I havent quite been able to figure out. The Documentation mentions that Operator overloading exists mainly for the Science Domains that should be supported. So I was trying to use operator overloading to create a simple way to do Vector Addition (Element Wise array addition). I know I could just make a loop instead but thats just in general less readable.
So far i tried to do it as follows:
But this does not seem to work is there a way to do this if anyone knows something good here it would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions