taro

490 Reputation

12 Badges

11 years, 222 days
Maple is to me difficult. The first version I bought was Maple9, and it was more than 15 years ago. But, I couldn't use it, feeling it too difficult. But, three years ago, I thought Maple might be helpful to my study, and since then, I have continued to learn Maple. As I got able to read the Maple help, I think that I could get to use maple better now than before. But, I feel that I am a beginner yet.

MaplePrimes Activity


These are questions asked by taro

Dear those who are in Mapleprimes,

 

As I can't understand how Maple calculate the quick sort, I write the present question, hoping that someone give me a hint.

In essence, nested procedure I cannot understand is this:

 

quicksort:=proc(A,m,n)

....................

if m<n then

quicksort(A,m,p-1);.................................(1)

quicksort(A,p+1,n)...................................(2) 

end if;

eval(A);

end proc:

 

Details were ommitted, but I have to say that p is the number between m and n, which is determined by ommitted parts of 

the procedure.

And, with this nested procedure, 

quicksort([2,4,1,5,3],1,5) is calculated.

 

What I want to know is how to process the parts of (1) and (2).

If after (1) is processed, (2) is processed, what is the value of p in (2).

Is it the p which is determined successively through processing nested value of (1)?

 

Thank you in advance.

 

taro

I saw the expression:

proc(a::array(1, mumeric))

the decration of a is array(a, numeric).

But, I can't find still now the expression of array(a, numeric) in HELP in maple.

In the term of array, it is written that it takes as arguments indexfcn, bounds, list.

as in  array( indexfcn, bounds, list).

1 in array(1, mumeric)) is bounds, and probably numeric in array might mean each terms of the array such as (1,2,3)

has to take the property of being numeric. But, it is not written in the term of array in the HELP of Maple.

Where can I find that syntax of array of array(1, numeric)?

 

Thanks in advance.

 

taro 

 

 

 

 

Dear people in Mapleprimes,

I calculated the following Quick Sort algorithm.

 

restart;
quicksort:=proc(A::array(1,numeric),
m::integer, n::integer) 
local partition, p;

partition:=proc(m,n)
i:=m;
j:=n;
x:=A[j];
while i<j do
if A[i]>x then
A[j]:=A[i];
j:=j-1;
A[i]:=A[j];
else
i:=i+1;
end if;
end do;
A[j]:=x;
p:=j;

end proc:

if m<n then
p:=partition(m,n);
quicksort(A,m,p-1);
quicksort(A,p+1,n);
end if;
eval(A);
end proc:

trace(quicksort);

a:=array([2,4,1,5,3]);

quicksort(a,1,5);

 

Then, in the answer, there was a sentence that

{--> enter , quicksort, , args = , a, , , 2, , , 2

........................

{--> enter , quicksort, , args = , a, , , 4, , , 5

I could understand the reason of the "{--> enter , quicksort, , args = , a, , , 2, , , 2," 

but, I could not understand why 4, , , 5 could appear here. I think there is no reason why n that is the number at 5 

increased from 2 to 5. I thought n continues to be 2.

I hope you will give me some hint for this understanding.

 

I thought it with a lot of time. And, I don't know whether this place is an appropriate place to ask this question.

But, I will be very glad if you teach me some of this.

 

Best wishes.

 

taro

 

 

 

 

 

Hello Those who are in Mapleprimes.

 

I want to know the meaning of [].

That is,

a:=[1,2,3];

b:=a[];

What were returned was 

b:=1,2,3

This result is the same as that obtained from

b:=op(a);

 

What kind of meaning does a[] have?

I want to know the logic of this expression.

Can I ask you about this?

Thank you in advance.

 

taro yamada 

 

 

 

 

 

To those who read this post.

 

I have a question about the property of local variables in a procedure.

Are names at the local variables in procedures, strings not names? 

If so, why can strings be evalated to have Integer, which is numbers for counting for continuing repetition? 

This is the code which searches for the maximum value. 

**************************************************

Max2 := proc()

local i, m :: string;
if nargs = 0 then
return -infinity
end if;
m:= args[1];
for i from 2 to nargs do
if args[i] > m then
m := args[i]
end if;
end do;
m;
end proc:
Max2(1,7,5,4,6,10,35,63.5,-10,5);

 ************************************************

type(a,name);

              this answer was true.

type(1, string)

              this answer was false, of course.

 

I limited the values of local variables to be string.

But, to the sequence 1,7,5,4,6,10,35,63.5,-10,5, any error messages wouldn't appear.

I hope any of you will give me an answer.

Thank you in advance.

 

taro yamada

 

 

 

 

 

First 15 16 17 18 19 20 Page 17 of 20