Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to separate set into subsets in Julia?

Tags:

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.

like image 939
Alex Craft Avatar asked Mar 29 '16 11:03

Alex Craft


1 Answers

XSuccess = getindex(X,find(Y))
XFail = getindex(X, find(x->x==0,Y))

Check the docs on array indexing

like image 51
Felipe Lema Avatar answered Oct 03 '22 17:10

Felipe Lema