There are list of inputs X and list of outputs Y. Each input can be either 1 success or 0 fail.
X = [6 7 8]
Y = [1 1 0]
What would be the Julia way to split the inputs X into two sets - success and fails?
XSuccess = [6 7]
XFails = [8]
I can do it with loops, but it seems that there are at least two better ways to solve it - with the find function and list comprehensions.
XSuccess = getindex(X,find(Y))
XFail = getindex(X, find(x->x==0,Y))
Check the docs on array indexing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With