Eliminating of consecutive columns with the same values, in two separate vectors with same length and dependant on that accordingly for for a third vector with same length

eliminating of consecutive columns with the same values, in two separate vectors with same length and dependant on that accordingly for for a third vector with same length.

Example:

x = [1, 2, 3, 2, 4, 5, 6, 3, 7…]
y = [1, 2, 3, 2, 4, 5, 6, 3, 7…]

z = [9, 8, 7, 6, 5, 4, 3, 2, 1…]

x’ = [1, 2, 3, 4, 5, 6, 7…]
y’ = [1, 2, 3, 4, 5, 6, 7…]

z’ = [9, 8, 7, 5, 4, 3, 1…]

is there an efficient way to realize that?

duplicate of Two separate vectors of same length and eliminating items in both vectors, whenever the values of those vectors are the same at identical columns. Depending on this the values of a third vector shall be eliminated accordingly - #2 by lmiq

have a close look. Not a duplicate!

What did you try? Are these homework?

yes, homework, started programming again after long time (Borland Pascal…long time ago) and detected Julia recently. Sorry for confusion. What I really need is this here … eliminating identical consecutive columns as per new example

XYZ=unique(e->first(e,2),zip(x,y,z))

ok, thank you very much!

and then to get it “unzipped”:

x = [x[1] for x in xyz]
y = [x[2] for x in xyz]
z = [x[3] for x in xyz]

You can also unzip with:

x, y, z = collect.(zip(xyz...))

zip is somewhat like matrix transpose, in that it is kind of its own inverse.

2 Likes

:ok_hand:

ids=last.(unique(first,(zip(zip(x,y),eachindex(x)))))
x[ids]
...