bobi

5 Reputation

One Badge

15 years, 88 days

MaplePrimes Activity


These are answers submitted by bobi

is it also possible to have subsop recplace multiple entries of a list, defined by a list itself?

My problem is as follows:

I want a list (A) to be scanned for zeroes. Maple shall then create a new list (B) with the positions of the zeroes in A. Next all zeroes shall be deleted from A, redefining the list A now to be zero-free. Simultaneously in another list (C), which has the same number of entries as list A, the positions defined in list B shall also be deleted:

A:=[5,0,1,0,0]; C:=[0.735,0,0.265,0,0]

extract zero-positions from A and save the slots information to --> B:=[2,4,5];

next delete all zeros from A --> A:=[5,1]

accordingly delete positions from list B in list C --> C:=[0.735,0.265]. How can this be done in one subsop-command?

 

Half-done example:

A:=[5,0,1,0,0];

n:=nops(A);

B:=[];

for i from 1 to n do

 if (A[i] = 0) then B:=[op(B),i] end if;

od;

A:=subsop(???=NULL,A);

C:=subsop(???=NULL,A);

??? shall be an expression referring to all integers defined in B. It's the same as doing subsop(B[1]=NULL,B[2]=NULL,B[3]=NULL,A).

Thanks in advance...

Matthew

 

 

Page 1 of 1