Question: Remove same (sepcific) elements from Vectors

Hi all,

Say i have two Vectors:

V1:=Vector(2,[a,b]);

V2:=Vector(4,[d,b,e,a]);

and how do I get

V3:=Vector([d,e]);

?? I currectly use a crude way using 'set' operations:

V3:=convert(V2,set) minus convert(V1,set);

V3:=convert(V3,Vector); # Does not work straightford, so

V3:=convert(V3,list):
V3:=convert(V3,Vector); # Which works,

 

Also, is there a strightforward way to which elements are the same and their indices?

in this case, I want indices like [2] and [4] (from V2).

 

Many thanks

restart:

V1:=Vector(2,[a,b]);

V1 := Vector(2, {(1) = a, (2) = b})

(1)

V2:=Vector(4,[d,b,e,a]);

V2 := Vector(4, {(1) = d, (2) = b, (3) = e, (4) = a})

(2)

V3:=Vector([d,e]);

V3 := Vector(2, {(1) = d, (2) = e})

(3)

V3:=convert(V2,set) minus convert(V1,set);

{d, e}

(4)

V3:=convert(V3,Vector);

Error, invalid input: `convert/Vector` expects its 1st argument, V, to be of type {Array, Matrix, Vector, array, list}, but received {d, e}

 

V3:=convert(V3,list):
V3:=convert(V3,Vector);

V3 := Vector(2, {(1) = d, (2) = e})

(5)

 

 



Download test.mw

 

Please Wait...