Parser in document mode don't work properly

lemelinm's picture

Hi everybody

 

p.276 from the advanced programming guide: example 2 line 11

> r := z = -3 .. 3;

                              r := z = -3 .. 3
> minz:=lhs('if'(r::range,r,rhs(r)));

Error, unable to match delimiters

I encounter a similar  problem of parsing once:
 

> H:=x-> if type(x,even) then print("Even"); else print("Odd"); end if:

Error, invalid arrow procedure

It seems to me that those two should work properly.  Of course, if I do
 

H:=proc(x) if type(x,even) then print("Even"); else print("Odd"); end if:end proc:

there is no problem.  I don't know if it work properly in Classic Worksheet 1D since I never been able to start a new worsheet in that mode.

In fact, when I open a new worksheet, I have the choice between worksheet mode (with the [> ) and document mode.  In both case, it's 2D Input

 

Mario

acer's picture

1D Maple notation input

Your post shows the wrong single-quote marks. They should both be left-quotes (name-quotes) and not right-quotes (unevaluation quotes) in order to use the postfix operator function `if`.

There are separate options settings for toggling Worksheet/Document and 1D/2D input modes, in the Standard GUI.

To set 1D input use the top menubar item Tools -> Options -> Display and use the top dropdown menu labelled "Input display". Set it to "Maple Notation" for 1D mode input.

In a Worksheet, the F5 function key toggles the cursor between 1D Maple input and 2D Math input (on Linux, so use the shortcuts for your OS). You can tell which mode the cursor is currently accepting visually: the cue is a slanted cursor for 2D and a vertical cursor for 1D mode.

acer

lemelinm's picture

It does not work either

I put

lhs(`if`(r::range,r,rhs(r))

and it's still doesn't work.

And how about the arrow  procedure for H?

 

mario.lemelin@cgocable.ca

Robert Israel's picture

Parentheses, and arrow

You're missing a right parenthesis.  Count them: three (, two ).

As for the other issue:

> H:=x-> if type(x,even) then print("Even"); else print("Odd"); end if:

does work in 1D input (both Classic and Standard), and 2D input in Classic but not Standard.  I guess that's a bug, but I wouldn't call it a serious one: arrow notation is really designed for a function that computes a single expression, rather than a complicated procedure with several statements.

acer's picture

syntax

(I had to edit this, to correct it)

This works for me, in 2D Math input mode, in Maple 12,

H := x -> `if`( type(x,even), print("Even"), print("Odd") );

There was a missing end bracket in the other example just above (the one using lhs).

acer

lemelinm's picture

That means it's time to stop.

Thanks for your help and patience

 

mario.lemelin@cgocable.ca

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}