joyceljy9990

50 Reputation

5 Badges

8 years, 264 days

MaplePrimes Activity


These are questions asked by joyceljy9990

I have the following command.

with(StringTools);
message := `Kajian ini mempunyai tiga objektif pertama seperti yang ditunjukkan dalam bahagian 1.11. Objektif tersebut harus`;

m := convert(message, bytes);

block := map(convert, m, binary);
block := map2(nprintf, "%08d", block);
block := map(proc (t) options operator, arrow; [seq(parse(convert(t, string)[i]), i = 1 .. length(convert(t, string)))] end proc, block);

block := [[0, 1, 0, 0, 1, 0, 1, 1], [0, 1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1], ........]

with(Bits);
for i to l do
for j from 3 to 7 do
block[i][j] := 1-block[i][j];  //used to flip bit in between 3rd to 7th bit in a block
end do;
c_block[i] := block[i];
end do;
c_block1 := [seq(c_block[i], i = 1 .. l)];

Error, assigning to a long list, please use Arrays

May i know how to solve this problem? I need to change some bit in a list but receive error when there is more than 100 elements in a list. Thank you.

Here is my command and i will use to make the user interface.

Orginal:

for i to l do

for j from x to y do

block[i][j] := 1-block[i][j]

end do;

c_block[i] := block[i];

c_block[i] := parse(cat(c_block[i][]))

end do

Can someone help me to edit my command so that i can write it in Click Edit Action for a button? thank you.

Do(for i from 1 to %l do)
   Do(for j from x to y do)
      Do(block[i][j] = 1-block[i][j]); 
    end do);
   Do(c_block[i] := block[i]);
  Do( c_block[i] := parse(cat(c_block[i][])));
end do);

How to reverse the order in a list?

example:

i have m := [1, 1, 0, 0, 1, 1, 1, 0]

I want to get the output like newm:=[0,1,1,1,0,0,1,1].

How to solve? Any command can help?

if m:= [01100101, 01101100, 01100111, 01100001];

I want to get [[0,1,1,0,0,1,0,1].[0,1,1,0,1,1,0,0],[0,1,1,0,0,1,1,1],[0,1,1,0,0,0,0,1]];

Any command can solve? Thank you.

I have the following command (credit to @Carl Love ), this command will do certain bit shifting with the next block, and the last block will shift with the first block. 

B:= Matrix([[0,0,1,1,0,0,1], [0,0,1,1,1,0,0],[0,1,0,1,0,1,0], [1,0,0,1,1,1,0]]):
Bnew:= copy(B):
Bnew[[4,1,2,3], 3..5]:= B[.., 3..5]:
Bnew; 

May i know any command can help to reverse the shifting position between the block?

for example,

original block  [0,0,1,1,0,0,1], [0,0,1,1,1,0,0],[0,1,0,1,0,1,0], [1,0,0,1,1,1,0]

i need to shift the 3..5 position of block 1 and change to the 5..3 position of block 2. 

Example:

After shifting, 

Bnew=[0,0,1,1,1,0,1],[0,0,0,1,0,0,0],[0,1,1,1,0,1,0],[1,0,0,1,1,1,0]

Any command can help to solve? thank you in advance.

1 2 3 Page 1 of 3