14 Badges

12 years, 183 days
East Grinstead, United Kingdom

Alternative Argument spelling in a proce...

Maple 2023

This is something I use a fair bit. I have procedures with alternative spelling options for the colours Red Green and Blue.
Have shown a single example copied from  an overloaded procedure. It there a nicer way of handling this than what I am doing?
There is a section in help under "Procedure Parameter Declarations" on "Indexed Keyword Parameters"  but I don't see how to use it here. These procedures are used inside a package.

 > restart
 >
 > GeomClr:="Blue";  # can be "Blue", "blue", "B", "b"  or;                   #        "Green", "green", "G", "g"  or;                   #        "Red2, "red", "R", "r"; Prntmsg:="y" ; #  or anything that is not"y"
 >
 (1)
 > spread:=proc(p0::{satisfies(s -> type(s, [algebraic \$ 2])),'Vector[row]'(2, algebraic)},               p1::{satisfies(s -> type(s, [algebraic \$ 2])),'Vector[row]'(2, algebraic)},               clr::`string`:= GeomClr,               prnt::`string`:=Prntmsg)            option overload;            uses LinearAlgebra;            #print(clr,p0,p1);            if clr="b" or clr="B" or clr="blue" or clr="Blue" then               if prnt="y" then                 print("Spread 2 [x,y] Points/Vectors wrt origin Blue");               end if;                return 1 - BilinearForm(p0, p1, conjugate = false)^2/(BilinearForm(p0, p0, conjugate = false)*BilinearForm(p1, p1, conjugate = false));            elif clr="g" or clr="G" or clr="green" or clr="Green" then               if prnt="y" then                print( "Spread 2 [x,y] Points/Vectors wrt origin Green");               end if;                return -1/4*(p0[1]*p1[2] - p0[2]*p1[1])^2/(p0[1]*p0[2]*p1[1]*p1[2]);            elif clr="r" or clr="R" or clr="red" or clr="Red" then               if prnt="y" then                print( "Spread 2 [x,y] Points/Vectors wrt origin Red");                end if;                return -(p0[1]*p1[2] - p0[2]*p1[1])^2/((p0[1]^2 - p0[2]^2)*(p1[1]^2 - p1[2]^2));           end if;           end proc:
 > sb:=spread(<3|2>,<4|-5>);
 (2)
 > sg:=spread(<3|2>,<4|-5>,"g");
 (3)
 > sr:=spread(<3|2>,<4|-5>,"r");
 (4)
 > 1/sb+1/sr+1/sg
 (5)
 > sr:=spread(<3|2>,<4|-5>,"r","n");
 (6)
 >

Download Q_2024-02-09_Alternative_Spelling_in_Proc.mw

Overload Procedures with default values ...

Maple 2023

The overloaded  procedure here test returns based on 2 lists or 3 lists entered. The two list has a mixed input type with a default value. The default value of "a" can cause a problem if an explicit value in not entered for "a" in foo1. I not sure is the mixed input type is adding to the problem.
By changing the order of the procedures the problem is avoidable here. But this just a simple example. When there are 6 or so procedures it can be very difficult to select a correct ordering.

Is there a way around this, apart from don't have default values?

I could experiment with changing the input order in each proc but that would break up some logical input sequences on me.

 > restart
 >
 > foo:=overload([                         proc(P1::list,P2::list,a::algebraic:=4,\$)                          option overload;                          print("2 lists");                           end proc,                        proc(P1::list,P2::list,P3::list,\$)                          option overload;                          print("3 lists");                           end proc                        ]);
 (1)
 > foo([1,2],[3,4])
 (2)
 > foo([1,2],[3,4],[4,7])
 (3)
 >
 >
 >
 > foo1:=overload([                                                 proc(P1::list,P2::list,P3::list,\$)                          option overload;                          print("3 lists");                           end proc,                         proc(P1::list,P2::list,a::algebraic:=4,\$)                          option overload;                          print("2 lists");                           end proc                        ]);
 (4)
 > foo1([1,2],[3,4]); #incorrect output
 (5)
 > foo1([1,2],[3,4],4)
 (6)
 > foo1([1,2],[3,4],[4,7])
 (7)
 >

Download 2024-02-3_Q_Overload_proc_.mw

Check if '=' is or is not in an equation...

How do i check if an equation or function does not contain an '=' sign, to convert it?

if eq:= a+b=c

If it has an  '=' I can use eq1:=lhs(eq)-rhs(eq).

If eq=d+e+f there is no lhs/rhs and checking produces an error.

```eq := a*x^2 + b*x = v;
2
eq := a x  + b x = v

eq1 := lhs(eq) - rhs(eq);
2
a x  + b x - v

eq2 := a*x^2 + b*x - v;
2
eq1 := a x  + b x - v

lhs(eq1);
Error, invalid input: lhs received a*x^2+b*x-v, which is not valid for its 1st argument, expr
NULL;
has(eq,'=');
Error, invalid uneval
Typesetting:-mambiguous(hasApplyFunction(eqcomma

Typesetting:-mambiguous((equals),

Typesetting:-merror("invalid uneval"))))

has(eq2, rhs(eq2));
Error, invalid input: rhs received eq2, which is not valid for its 1st argument, expr
NULL;
```

Inputs to whorksheet changed after windo...

Maple 2023

I have done a complete clean reinstall of windows 10 and all programs on my pc.

In worksheet mode new files do not have the "default" red/brown text coluor ond the font is different.

Might not be a problem but thought that was the default?

What have I changed or have Maple defaults changed?

 >
 >
 >
 (1)
 >
 >
 (2)
 >

Download 23-11-23_Q_inputs_to_worksheet_not_brown_red_colour.mw

Animate a Line....

Maple 2023

I am asking this beacuse I am rusty on using animate in plots. Just trying to show the line segment moving.

 (1)

Download 23-11-03_Q_Animate_a_line.mw

 First 7 8 9 10 11 12 13 Last Page 9 of 32
﻿