Notifications
Clear all

[Closed] Fast way to find/locate /delete apart of an array?

I want to find a sub array whether in an array,something like this:

Array need to find:
arr_a=#(3,4,5,6,7)

arr_b=#(0,1,2,3,4,5,6,7,8,9)
–arr_a is part of arr_b

arr_c=#(1,2,4,5,6,8,9)
–arr_a is NOT part of arr_b

From example of above,

1.how do I know if arr_b include arr_a?
2.If arr_b include arr_a,how can I get the location of arr_a in arr_b?
3.If I want to delete arr_a part in arr_b,how to do that?
arr_b=#(0,1,2,3,4,5,6,7,8,9)
->
arr_b=#(0,1,2,8,9)

Thanks for any help!

6 Replies

google is your everything

Thanks for help!

are finding stuff like vert or face indices ? if you are then using bitarrays does this stuff far far faster and effieciently.

Is there an example?I will handle binary array,so speed is very important,thanks.

a_bits = #{1..24}
b_bits = #{6..9}
c_bits = #{25..128}

d_bits = a_bits * b_bits -- and bitarrays
e_bits = a_bits - b_bits -- subtract 
f_bits = e_bits + c_bits -- add

arry = f_bits as array -- convert

you can also use them like arrays in for loops e.g

for v in e_bits do print v

Thanks for help,I will try your method later.