## 50 Reputation

8 years, 148 days

## How to assign a long list by using Array...

Maple

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.

## Can 'for' be coded in Components? ...

Maple

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);

## Reverse the order of a list...

Maple

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?

## How to add comma to binary number?...

Maple

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.

## Shifting between block...

Maple

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
﻿