0

I try to write functions in mupad but it seems I haven't understood how procedures and identifiers work. I get every time the message "Error: Unexpected 'identifier'". First example: I tried changing the first row of a given matrix to [1 1 ... 1]. I wrote the following code:

shibutz:=proc(B)
begin
cons:=Dom::Matrix():
l:=max(cons::matdim(B));
for k from 1 to l do
B[1,k]:=1;
end_for
print(B);
end_proc

Second example: Another code which gets the same error is a procedure I wrote verifying goldbach theorm that every even number is sum of two prime numbers:

golbach:=proc(n)
begin
flag=bool(9<8);
theprimes:=select([$2..n-1],isprime);
for k from 1 to nops(theprimes) do
if(isprime(n-k)=TRUE) then
flag=bool(1>0);
end_if
end_for
return (flag);
end_proc

What am I doing wrong? which identifiers mupad didn't expect?

Danis Fischer
  • 375
  • 1
  • 7
  • 27
  • What have you tried in terms of debugging? I haven't used mupad myself, but when I tried your first piece of code (`shibutz`), I got an error in `line 8`, which is your `print` statement. I know that `print` itself should work, so I assume that something in the loop went wrong. Are the values for `cons` and `l` what you expect them to be? – Schorsch Jun 25 '13 at 13:45

1 Answers1

0

I just jorgot ; in the end of the loop (it had to be end_for;) and furthermore I forgot : before the = (so it had to be := and not =). Sorry for dumb question.

Danis Fischer
  • 375
  • 1
  • 7
  • 27