# 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

**URL:** <https://discourse.julialang.org/t/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/94422>\
**Category:** General Usage\
**Tags:** question, vector\
**Created:** [February 10, 2023, 5:59pm UTC](https://discourse.julialang.org/t/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/94422 "2023-02-10T17:59:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratwolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ratwolf/32/46600_2.png) [@ratwolf](https://discourse.julialang.org/u/ratwolf)\
**Post date:** [February 10, 2023, 5:59pm UTC](https://discourse.julialang.org/t/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/94422/1 "2023-02-10T17:59:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 10, 2023, 6:40pm UTC](https://discourse.julialang.org/t/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/94422/2 "2023-02-10T18:40:25Z")

</div>

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](https://discourse.julialang.org/t/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/94371/2)

---

<div class="post-metadata">

**Author:** ![ratwolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ratwolf/32/46600_2.png) [@ratwolf](https://discourse.julialang.org/u/ratwolf)\
**Post date:** [February 10, 2023, 6:47pm UTC](https://discourse.julialang.org/t/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/94422/3 "2023-02-10T18:47:58Z")

</div>

have a close look. Not a duplicate!

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 10, 2023, 7:11pm UTC](https://discourse.julialang.org/t/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/94422/4 "2023-02-10T19:11:00Z")

</div>

What did you try? Are these homework?

---

<div class="post-metadata">

**Author:** ![ratwolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ratwolf/32/46600_2.png) [@ratwolf](https://discourse.julialang.org/u/ratwolf)\
**Post date:** [February 10, 2023, 7:29pm UTC](https://discourse.julialang.org/t/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/94422/5 "2023-02-10T19:29:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [February 10, 2023, 8:55pm UTC](https://discourse.julialang.org/t/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/94422/6 "2023-02-10T20:55:22Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![ratwolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ratwolf/32/46600_2.png) [@ratwolf](https://discourse.julialang.org/u/ratwolf)\
**Post date:** [February 11, 2023, 1:27am UTC](https://discourse.julialang.org/t/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/94422/7 "2023-02-11T01:27:38Z")

</div>

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]

 ![Screenshot 2023-02-11 at 02.23.21](https://global.discourse-cdn.com/julialang/original/3X/6/c/6ca2679a31209e5df4bd6b5cdb58d209d9f569b9.png)

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [February 11, 2023, 2:08am UTC](https://discourse.julialang.org/t/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/94422/8 "2023-02-11T02:08:03Z")

</div>

You can also `unzip` with:

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

```

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

---

<div class="post-metadata">

**Author:** ![ratwolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ratwolf/32/46600_2.png) [@ratwolf](https://discourse.julialang.org/u/ratwolf)\
**Post date:** [February 11, 2023, 2:40am UTC](https://discourse.julialang.org/t/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/94422/9 "2023-02-11T02:40:29Z")

</div>

👌

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [February 11, 2023, 7:11am UTC](https://discourse.julialang.org/t/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/94422/10 "2023-02-11T07:11:20Z")

</div>

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

```
