cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Create new vector based on element pairs of another vector

Gaz_Ball
6-Contributor

Create new vector based on element pairs of another vector

I have a vector [A], which can have any number of even rows and will contain only zeros or ones in each element. I would then like to create another vector [B], which will always have one more than half the number of rows in [A]. The top row element of [B] is always 1, and the following elements depend on the corresponding pairs of elements in [A], working from top to bottom. The element of [B] should be zero only if both the corresponding two elements of [A] are zero, otherwise it should be one. Something like this for a 4 row [A] and 3 row [B]:

Gaz_Ball_0-1663922674898.png

Gaz_Ball_1-1663922712973.png

Gaz_Ball_2-1663922738004.png

Gaz_Ball_3-1663922777475.png

Gaz_Ball_4-1663922799327.png

 

And for a 6 row [A] and 4 row [B]:

Gaz_Ball_0-1663924279543.png

 

Hopefully someone can help me out!
Thanks.

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:Gaz_Ball)

Here's a possible implementation of your function:

LucMeekes_0-1663927302351.png

Result(s):

LucMeekes_2-1663927357556.png

LucMeekes_1-1663927331554.png

If you cannot read the attached file, you must state which version of Prime you are using.

 

Success!
Luc

 

View solution in original post

2 REPLIES 2
LucMeekes
23-Emerald III
(To:Gaz_Ball)

Here's a possible implementation of your function:

LucMeekes_0-1663927302351.png

Result(s):

LucMeekes_2-1663927357556.png

LucMeekes_1-1663927331554.png

If you cannot read the attached file, you must state which version of Prime you are using.

 

Success!
Luc

 

Gaz_Ball
6-Contributor
(To:LucMeekes)

Thanks Luc, that's great!

Announcements

Top Tags