Ronan

1381 Reputation

16 Badges

13 years, 291 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@mmcdara  Ahh. I use Geomclr:= "...." as the global colour setting but can be changed specifically.

I now notice you put the optional parameters in {  }. The makes you have to do clr =...    but has the advantage of allowing skipping one if desired. Nice. 

@acer 

I have experimented with catching an incorrect input. How should I get it to produce an error instead on skipping on. An empty input p() is fine.
 

restart;

p := proc(c::coerce(proc(s::string)
                      local L:=StringTools:-LowerCase(s);
                      piecewise(member(L,["blue","b"]),"Blue",
                                member(L,["green","g"]),"Green",
                                member(L,["red","r"]),"Red",
                               `not`(menber(L,["blue","b","green","g","red","r"])))
                    end proc):="Blue")

  return c;

end proc:

p("bLUe"), p("Blue"), p("blue"), p("b"), p("B");
             "Blue", "Blue", "Blue", "Blue", "Blue"

p("ReD"), p("Red"), p("red"), p("r"), p("R");
               "Red", "Red", "Red", "Red", "Red"

p("GreEn"), p("Green"), p("green"), p("g"), p("G");
          "Green", "Green", "Green", "Green", "Green"

p("God"),p("black")

 not menber("god", ["blue", "b", "green", "g", "red", "r"]), 

   not menber("black", ["blue", "b", "green", "g", "red", "r"])


p()
                             "Blue"

 

@mmcdara This makes things much neater. I will try setting it up as a procedure that is called inside the package, as this is used in various places. Yes I do need to put in checks for the 0 denominator.

I notice one has to enter
spread2(...clr="Red" , prnt =false) 
instead of
spread2(....."Red" , false)

Why is that? 


  I do like that you skip clr
spread2(p0 , p1, prnt=false)

 Module...
    export spread....,
 Coltest(clr)
local col := substring(StringTools:-Capitalize(clr), 1..1);
           local COL := `if`(col="R", "Red", `if`(col="G", "Green", "Blue"))  
return col
end proc;
spread2:=proc(
               ....
               {clr::string:="Blue"}, 
               {prnt::boolean:=true}
             )
           ....
          Coltest(clr); 
           ....
           if `not`(member(col, {"R", "G", "B"})) then
             error cat("allowed colors are red, green or blue, received ", clr)
           end if:

           if prnt then
             print(cat("Spread 2 [x,y] Points/Vectors wrt origin ",  COL));
           end if:
                 
           if col = "B" then
               return ....

           elif col="G" then
               return ....

           elif col="R" then
               return ....
          end if;
          end proc:



 

 

 

@Carl Love Firstly, appologies for the delay in replying. I understand what was happening better now. I evolved my way through things this week.

What works to prevent unintended evaluation in the overload situation has been to use all the inputs for each overload scenario. I kept being caught out by just printing messages withoud using the parameters/arguments,

Have two versions "test" and "test1" where the order of the procedures in the list are completly reversed. Both work nicely and have not hit any unintended eveluations. I have left many of my evolving notes in.

The setup seem to be reliable for invalid inputs too.
 

restart

GCb:="Blue"

"Blue"

(1)


        test :=overload([

#1;
proc(p0::algebraic,$)
option overload;
[p0];
print("#1 single 1D input. No colour check required");

end,

#2;
proc(p0::algebraic,p1::algebraic,$)
option overload;
[p0,p1];
print("#2 pair of 1D inputs. No colour check required");
end,

#3;
proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     clr::`string` := GCb,$)
                option overload;
global GCb;
[p0,clr];
if clr="Blue"  then
   print("#3 input recognised 2D Point/Vector. Blue.") ;
 elif clr= "Red" or clr="Green" then
 print("#4 inputs recognised 2D Point/Vector. Red or Green");
end if;
end,

#4 If put before #3 causes false evaluation of #3 type input #4
#  [p0,p1,clr]  cures the problem because it itse the inputs ;
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` := GCb,$)
                option overload;
global GCb;
[p0,p1,clr];
if clr="Blue"  then
   print("#4 inputs recognised pair of 2D Points/Vectors.Valid for Blue.") ;
 elif clr= "Red" or clr="Green" then
 print("#4 inputs recognised pair of 2D Points/Vectors. Red or Green");
end if;
end,

#4X;  If this is moved to before 4 causes false evaluation of #4 type input #4X 
#  [p0,p1,p2,clr]  cures the problem because it itse the inputs;    
proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     p1::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     p2::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     clr::`string` := GCb,$)
                option overload(callseq_only);
global GCb;
[p0,p1,p2,clr];
if clr="Blue" or clr="Red" or clr="Green" then
   print("#4X inputs recognised Set of 3 2D Points/Vectors.Valid for Blue, Red & Green") ;
end if;
end,


#5;
proc(p0::{satisfies(s -> type(s, [algebraic $ 3])),'Vector[row]'(3, algebraic)},
     clr::`string` := GCb,$)
                option overload;
global GCb;
[p0,clr];
if clr="Blue"  then
   print("#5 inputs recognised single 3D Point/Vector");
     else  print("#5  error 3D Point/Vector only valid for Blue Geometry");
end if;
end,

#6;
proc(p0::{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)},
     p1::{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)},
     clr::`string` := GCb,$)
                option overload;
global GCb;
[p0,p1,clr];
if clr="Blue" then
    print("#6 inputs recognised pair of 3D Points/Vectors ") ;
      else print("#6 3D points/vectors only valid for Blue Geometry");
end if;
end,

#7;
proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     pl::{satisfies(s -> type(s, [algebraic $ 3])),'Vector[column]'(3, algebraic),`+`,procedure},var::satisfies(s -> type(s, [algebraic $ 2])):=[x,y],
     clr::`string` := GCb,$)
        option overload;
[p0,pl,clr];
print("#7 inputs recognised 2D Point and Line valid for Blue, Red & Green") ;
end,
#8;
proc(l1::satisfies(s -> type(s, [algebraic $ 3])),
     l2::[{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)}, 'Vector[column]'(3, algebraic)],$)
option overload;
[l1,l2];
print("#8 inputs recognised 3D Point and 3D Line.No colour check Blue only");
 end,


#9  if put before #5 it causes false evaluation of #5 type inputs as #9 
#    [p0,pl,vars] cure ;
proc(p0::{satisfies(s -> type(s, [algebraic $ 3])),'Vector[row]'(3, algebraic)},
     pl::{'Vector[column]'(4, algebraic), `+`,procedure},var::satisfies(s -> type(s, [algebraic $ 3])):=[x,y,z],$)
        option overload;
global gcb;
[p0,pl,vars];
print("#9 inputs recognised 3D Point and Plane.No colour check Blue only");
end,

#10;
 proc(l1::[{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)}, 'Vector[column]'(3, algebraic)],
      l2::[{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)}, 'Vector[column]'(3, algebraic)],$)
        option overload;
[l1,l2];
print("#10 inputs recognised   Skew lines 3D.No colour check Blue only") ;
end

]):

        


 

 

#  3d lines  a list or row vector for position point and column vector for direction

l1:= [<1 | 5 | 7>, <3, 7, 9>];   #3D line

[Vector[row](3, {(1) = 1, (2) = 5, (3) = 7}), Vector(3, {(1) = 3, (2) = 7, (3) = 9})]

(2)

l2:=[<-4 | 2 | 1>, <3, 8, -9>];  #3D line

[Vector[row](3, {(1) = -4, (2) = 2, (3) = 1}), Vector(3, {(1) = 3, (2) = 8, (3) = -9})]

(3)

 

l3:= [[1 , 5 , 7], <3, 7, 9>]; #3D line

[[1, 5, 7], Vector(3, {(1) = 3, (2) = 7, (3) = 9})]

(4)

l4:=[[-4 , 2, 1 ], <3, 2, -9>];  #3D line

[[-4, 2, 1], Vector(3, {(1) = 3, (2) = 2, (3) = -9})]

(5)

# 1 & 2 inputs

test(R);
test(R,R)

"#1 single 1D input. No colour check required"

 

"#2 pair of 1D inputs. No colour check required"

(6)

# 3 inputs

test([a,b]);

test(<a|b>);

"#3 input recognised 2D Point/Vector. Blue."

 

"#3 input recognised 2D Point/Vector. Blue."

(7)

# 4 inputs

test([a,b],[e,t]);
test([a,b],[e,t],"Green");
test(<a|b>,<e|t>,"Red");

 

"#4 inputs recognised pair of 2D Points/Vectors.Valid for Blue."

 

"#4 inputs recognised pair of 2D Points/Vectors. Red or Green"

 

"#4 inputs recognised pair of 2D Points/Vectors. Red or Green"

(8)

# 4X inputs

test([a,b],[a,c],[d,e])

"#4X inputs recognised Set of 3 2D Points/Vectors.Valid for Blue, Red & Green"

(9)

# 5 inputs

test([a,b,c],"Blue");
test([a,b,c]);
test([a,b,c],"Red");
test(<a|b|c>);

"#5 inputs recognised single 3D Point/Vector"

 

"#5 inputs recognised single 3D Point/Vector"

 

"#5  error 3D Point/Vector only valid for Blue Geometry"

 

"#5 inputs recognised single 3D Point/Vector"

(10)

#6 inputs

test([a,b,c],[d,e,f]);
test([a,b,c],[d,e,f],"Red");
test(<a|b|c>,<d|e|f>);

"#6 inputs recognised pair of 3D Points/Vectors "

 

"#6 3D points/vectors only valid for Blue Geometry"

 

"#6 inputs recognised pair of 3D Points/Vectors "

(11)

#7 inputs

test([a,b], <3, 2,d>,"Red");

test([a,b], 3*x+ 2*y+d);

test([a,b], 3*p+ 2*q+d,[p,q]);
f:=(p,q)-> 3*p+ 2*q+d;
test([a,b],f(p,q),[p,q])

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

 

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

 

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

 

proc (p, q) options operator, arrow; 3*p+2*q+d end proc

 

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

(12)

# 8 inputs

test([a,b,c],l1);
test([a,b,c],l2);
test([a,b,c],l3);
test([a,b,c],l4);

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

 

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

 

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

 

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

(13)

#9 inputs

test( [s,g,h],<1,2,3,4>);
test( [s,g,h],x+2*y+3*z+4);
test( [s,g,h],5*r-6*s+k*t+g,[r,s,t]);
h:=(r,s,t)-> 3*r+ 2*s-7*t+6 : #  a plane
test( [s,g,h],h(r,s,t),[r,s,t])

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

 

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

 

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

 

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

(14)

#10 inputs

test(l3,l4);
test(l1,l2);
test(l1,l3);

"#10 inputs recognised   Skew lines 3D.No colour check Blue only"

 

"#10 inputs recognised   Skew lines 3D.No colour check Blue only"

 

"#10 inputs recognised   Skew lines 3D.No colour check Blue only"

(15)

#false/incorrect type inputs working correctly as required

test()

Error, invalid input: no implementation of test matches the arguments in call, 'test()'

 

 

test([a,b,d],[a,c,f],[d,e,n])

Error, invalid input: no implementation of test matches the arguments in call, 'test([a, b, d],[a, c, f],[d, e, n])'

 

test(1,2,3)

Error, invalid input: no implementation of test matches the arguments in call, 'test(1,2,3)'

 

test([a,b], 3*p+ 2*q+d,[p,q],[e,t]);

Error, invalid input: no implementation of test matches the arguments in call, 'test([a, b],3*p+2*q+d,[p, q],[e, t])'

 

test( [s,g,h],h(r,s,t),[r,s,t],2)

Error, invalid input: no implementation of test matches the arguments in call, 'test([s, g, h],h(r,s,t),[r, s, t],2)'

 

test( [s,g,h],5*r-6*s+k*t+g,[r,s,t],"Blue")

Error, invalid input: no implementation of test matches the arguments in call, 'test([s, g, h],k*t+g+5*r-6*s,[r, s, t],"Blue")'

 

test(2,[a,b])

Error, invalid input: no implementation of test matches the arguments in call, 'test(2,[a, b])'

 

test([1,2,3,4,5])

Error, invalid input: no implementation of test matches the arguments in call, 'test([1, 2, 3, 4, 5])'

 

test(5*r-6*s+k*t+g,[r,s,t],[s,g,h])

Error, invalid input: no implementation of test matches the arguments in call, 'test(k*t+g+5*r-6*s,[r, s, t],[s, g, h])'

 

 

restart

GCb:="Blue"

"Blue"

(16)

 

 


        test1 :=overload([

#10;
 proc(l1::[{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)}, 'Vector[column]'(3, algebraic)],
      l2::[{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)}, 'Vector[column]'(3, algebraic)],$)
        option overload;
[l1,l2];
print("#10 inputs recognised   Skew lines 3D.No colour check Blue only") ;
end,

#9  if put before #5 it causes false evaluation of #5 type inputs as #9 Is there a way of checking p1 and  triger overload or if not presest?
#    [p0,pl,vars] cure ;
proc(p0::{satisfies(s -> type(s, [algebraic $ 3])),'Vector[row]'(3, algebraic)},
     pl::{'Vector[column]'(4, algebraic), `+`,procedure},var::satisfies(s -> type(s, [algebraic $ 3])):=[x,y,z],$)
        option overload;
global gcb;
[p0,pl,vars];
print("#9 inputs recognised 3D Point and Plane.No colour check Blue only");
end,

#8;
proc(l1::satisfies(s -> type(s, [algebraic $ 3])),
     l2::[{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)}, 'Vector[column]'(3, algebraic)],$)
option overload;
[l1,l2];
print("#8 inputs recognised 3D Point and 3D Line.No colour check Blue only");
 end,
#7;
proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     pl::{satisfies(s -> type(s, [algebraic $ 3])),'Vector[column]'(3, algebraic),`+`,procedure},var::satisfies(s -> type(s, [algebraic $ 2])):=[x,y],
     clr::`string` := GCb,$)
        option overload;
[p0,pl,clr];
print("#7 inputs recognised 2D Point and Line valid for Blue, Red & Green") ;
end,
#6;
proc(p0::{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)},
     p1::{satisfies(s -> type(s, [algebraic $ 3])), 'Vector[row]'(3, algebraic)},
     clr::`string` := GCb,$)
                option overload;
global GCb;
[p0,p1,clr];
if clr="Blue" then
    print("#6 inputs recognised pair of 3D Points/Vectors ") ;
      else print("#6 3D points/vectors only valid for Blue Geometry");
end if;
end,

#5;
proc(p0::{satisfies(s -> type(s, [algebraic $ 3])),'Vector[row]'(3, algebraic)},
     clr::`string` := GCb,$)
                option overload;
global GCb;
[p0,clr];
if clr="Blue"  then
   print("#5 inputs recognised single 3D Point/Vector");
     else  print("#5  error 3D Point/Vector only valid for Blue Geometry");
end if;
end,

#4X;  If this is moved to before 4 causes false evaluation of #4 type input #4X 
#  [p0,p1,p2,clr]  cures the problem because it itse the inputs;    
proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     p1::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     p2::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     clr::`string` := GCb,$)
                option overload(callseq_only);
global GCb;
[p0,p1,p2,clr];
if clr="Blue" or clr="Red" or clr="Green" then
   print("#4X inputs recognised Set of 3 2D Points/Vectors.Valid for Blue, Red & Green") ;
end if;
end,

#4 If put before #3 causes false evaluation of #3 type input #4
#  [p0,p1,clr]  cures the problem because it itse the inputs ;
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` := GCb,$)
                option overload;
global GCb;
[p0,p1,clr];
if clr="Blue"  then
   print("#4 inputs recognised pair of 2D Points/Vectors.Valid for Blue.") ;
 elif clr= "Red" or clr="Green" then
 print("#4 inputs recognised pair of 2D Points/Vectors. Red or Green");
end if;
end,

#3;
proc(p0::{satisfies(s -> type(s, [algebraic $ 2])),'Vector[row]'(2, algebraic)},
     clr::`string` := GCb,$)
                option overload;
global GCb;
[p0,clr];
if clr="Blue"  then
   print("#3 input recognised 2D Point/Vector. Blue.") ;
 elif clr= "Red" or clr="Green" then
 print("#4 inputs recognised 2D Point/Vector. Red or Green");
end if;
end,

#2;
proc(p0::algebraic,p1::algebraic,$)
option overload;
[p0,p1];
print("#2 pair of 1D inputs. No colour check required");
end,

#1;
proc(p0::algebraic,$)
option overload;
[p0];
if _params['p0']=NULL then `error nothing entered`
else print("#1 single 1D input. No colour check required");
end if;
end
]):

 

#  3d lines  a list or row vector for position point and column vector for direction

l1:= [<1 | 5 | 7>, <3, 7, 9>];   #3D line

[Vector[row](3, {(1) = 1, (2) = 5, (3) = 7}), Vector(3, {(1) = 3, (2) = 7, (3) = 9})]

(17)

l2:=[<-4 | 2 | 1>, <3, 8, -9>];  #3D line

[Vector[row](3, {(1) = -4, (2) = 2, (3) = 1}), Vector(3, {(1) = 3, (2) = 8, (3) = -9})]

(18)

 

l3:= [[1 , 5 , 7], <3, 7, 9>]; #3D line

[[1, 5, 7], Vector(3, {(1) = 3, (2) = 7, (3) = 9})]

(19)

l4:=[[-4 , 2, 1 ], <3, 2, -9>];  #3D line

[[-4, 2, 1], Vector(3, {(1) = 3, (2) = 2, (3) = -9})]

(20)

 

# 1 & 2 inputs

test1(R);
test1(R,R)

"#1 single 1D input. No colour check required"

 

"#2 pair of 1D inputs. No colour check required"

(21)

# 3 inputs

test1([a,b]);

test1(<a|b>);

"#3 input recognised 2D Point/Vector. Blue."

 

"#3 input recognised 2D Point/Vector. Blue."

(22)

# 4 inputs

test1([a,b],[e,t]);
test1([a,b],[e,t],"Green");
test1(<a|b>,<e|t>,"Red");

"#4 inputs recognised pair of 2D Points/Vectors.Valid for Blue."

 

"#4 inputs recognised pair of 2D Points/Vectors. Red or Green"

 

"#4 inputs recognised pair of 2D Points/Vectors. Red or Green"

(23)

# 4X inputs

test1([a,b],[a,c],[d,e])

"#4X inputs recognised Set of 3 2D Points/Vectors.Valid for Blue, Red & Green"

(24)

# 5 inputs

test1([a,b,c],"Blue");
test1([a,b,c]);
test1([a,b,c],"Red");
test1(<a|b|c>);

"#5 inputs recognised single 3D Point/Vector"

 

"#5 inputs recognised single 3D Point/Vector"

 

"#5  error 3D Point/Vector only valid for Blue Geometry"

 

"#5 inputs recognised single 3D Point/Vector"

(25)

#6 inputs

test1([a,b,c],[d,e,f]);
test1([a,b,c],[d,e,f],"Red");
test1(<a|b|c>,<d|e|f>);

"#6 inputs recognised pair of 3D Points/Vectors "

 

"#6 3D points/vectors only valid for Blue Geometry"

 

"#6 inputs recognised pair of 3D Points/Vectors "

(26)

#7 inputs

test1([a,b], <3, 2,d>,"Red");

test1([a,b], 3*x+ 2*y+d);

test1([a,b], 3*p+ 2*q+d,[p,q]);
f:=(p,q)-> 3*p+ 2*q+d;
test1([a,b],f(p,q),[p,q])

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

 

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

 

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

 

proc (p, q) options operator, arrow; 3*p+2*q+d end proc

 

"#7 inputs recognised 2D Point and Line valid for Blue, Red & Green"

(27)

# 8 inputs

test1([a,b,c],l1);
test1([a,b,c],l2);
test1([a,b,c],l3);
test1([a,b,c],l4);

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

 

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

 

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

 

"#8 inputs recognised 3D Point and 3D Line.No colour check Blue only"

(28)

#9 inputs

test1( [s,g,h],<1,2,3,4>);
test1( [s,g,h],x+2*y+3*z+4);
test1( [s,g,h],5*r-6*s+k*t+g,[r,s,t]);
h:=(r,s,t)-> 3*r+ 2*s-7*t+6 : #  a plane
test1( [s,g,h],h(r,s,t),[r,s,t])

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

 

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

 

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

 

"#9 inputs recognised 3D Point and Plane.No colour check Blue only"

(29)

#10 inputs

test1(l3,l4);
test1(l1,l2);
test1(l1,l3);

"#10 inputs recognised   Skew lines 3D.No colour check Blue only"

 

"#10 inputs recognised   Skew lines 3D.No colour check Blue only"

 

"#10 inputs recognised   Skew lines 3D.No colour check Blue only"

(30)

#false/incorrect type inputs working correctly as required

test1()

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1()'

 

 

test1([a,b,d],[a,c,f],[d,e,n])

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1([a, b, d],[a, c, f],[d, e, n])'

 

test(1,2,3)

test(1, 2, 3)

(31)

test1([a,b], 3*p+ 2*q+d,[p,q],[e,t]);

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1([a, b],3*p+2*q+d,[p, q],[e, t])'

 

test1( [s,g,h],h(r,s,t),[r,s,t],2)

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1([s, g, h],h(r,s,t),[r, s, t],2)'

 

test1( [s,g,h],5*r-6*s+k*t+g,[r,s,t],"Blue")

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1([s, g, h],k*t+g+5*r-6*s,[r, s, t],"Blue")'

 

test1(2,[a,b])

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1(2,[a, b])'

 

test1([1,2,3,4,5])

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1([1, 2, 3, 4, 5])'

 

test1(5*r-6*s+k*t+g,[r,s,t],[s,g,h])

Error, invalid input: no implementation of test1 matches the arguments in call, 'test1(k*t+g+5*r-6*s,[r, s, t],[s, g, h])'

 

 


 

Download Q_2024-02-08_Proc_types_in_list_inputs.mw

@Preben Alsholm Thank you. So this is a case of my "understanding" being an assumption. i.e. I always thought if the proc input had parameters that did not have default values one had to enter them all or an error would occur. Not so then if a particular one or more is not used, it can be ommitted. Of course that would be the last ones in the inputs.That is a very interesting subtle point..
 

restart;
foo1:=overload([                        
                  proc(P1::list,P2::list,P3::list,P4::list,$) # 4 list inputs
                     option overload;
                     print("3 lists");
                  end proc,

                  proc(P1::list,P2::list,a::algebraic:=4,$)
                     option overload;
                     print("2 lists");
                  end proc
                       ]):
foo1([1,2],[3,4]); #Output correct because P1 and P2 are lists P3 and P4 ommited
foo1([1,2],[3,4],4); 
foo1([1,2],[3,4],[4,7]); 

@Preben Alsholm Yes. My undarstanding was that if the inputs do not satisfy the input criteria of a procedure the next procedure is checked. There apperas to be more to it than that.

I suppose a work around would be to repeat  the inputs blandly for each proc in the list to force usage.

 {[
proc(P1... P3  )
option...
[P1,P2,P3]
.....
end proc,

proc(P1::type.. ,P2::type...,a::type...:=4)
option.....
[P1,P2,a]
......

end proc
])

and




 

@Preben Alsholm Thank you.  There is still something I don't quiet understand yet. I see if I didn't specifically use P3 in 1st proc , I get the inorrect output.  I know that would mean redundant input whic is not good.

foo2:=overload([                   
                  proc(P1::list,P2::list,P3::list,$)
                      option overload(callseq_only);
                   return  [P1,P2,P3],"3lists";
                  end proc,
                  proc(P1::list,P2::list,a::algebraic:=4,$)
                      option overload;
                     
                   return  [P1,P2],"2 lists"
                  end proc
                       ]):
foo2([1,2],[3,4]); 
foo2([1,2],[3,4],5);
foo2([1,2],[3,4],[4,7]);
                  [[1, 2], [3, 4]], "2 lists"

                  [[1, 2], [3, 4]], "2 lists"

               [[1, 2], [3, 4], [4, 7]], "3lists"

foo3:=overload([                   
                  proc(P1::list,P2::list,P3::list,$)
                      option overload(callseq_only);
                     #2*P3; # using this line it all work correctly;
                   return  "3lists";
                  end proc,
                  proc(P1::list,P2::list,a::algebraic:=4,$)
                      option overload;
                     
                   return  "2 lists"
                  end proc
                       ]):
foo3([1,2],[3,4]); #incorrect output;
foo3([1,2],[3,4],5);
foo3([1,2],[3,4],[4,7]);
                            "3lists"

@JAMET It would be much easier for people to help you if you upload your worksheet/document., 

Why all theinverted commas "............."?

There are numerious  places semicolins are missing.

In you plotting for F1 remove what is highlighted in red

 F1(color = black, symbol = soli4*yM2, yM1^2*dcircle, symbolsize=12)

then it works

@rlopez Isee you also posted something on Marden's Theoren.

@Carl Love This best example I have righrt now is in my reply here to a question How to draw an ellipse cut by lies - MaplePrimes  This made extensive use of factrix.   

Download 2023-12-23_A_Pascal_Conic_parameterised.mw

@Carl Love General Euclidean domain with rational functions eg parameterisation of a circle 

[(1-t^2)/(1+t^2) , 2t/(1+t^2 , 1]

Also there are square roots. I am playing around a lot with conic sections so plenty of square roots popup.

@Carl Love I will test this when at home over the next day or two. I was wondendering about approaching the problem using gcd and fold. Did't try anything yet. Can 'igcd' and 'ilcm' be replaced with 'gcd' and 'lcm'. The reason I ask is I mostly use factrix for projective geometry. Often  symbolic expressions are in the vectors, where row form represents a point and column form a line. Rescaling is really useful in that application.

 

  Didn't know I couldn't repost it here. Thanks for the link to the Maple Advisor Database.

@Carl Love Thank you. I confess I do not understand the code.e.g. Why do you start off with __M ?

 @C_R @mmcdara ​​​​​​​@acer ​​​​​​​  All good answers, I was playing around with my answer to this quastion on Pascals Theorem How to draw an ellipse cut by lies - MaplePrimes    to represent the conics as matrices. Sometimes its nicer to have e.g. x^2+y^2=R^2 and at times x^2+y^2-R^2 is just better. One of the procedures can now handle either automatically.  Good the see all the different apraoches. Mixed collections my well turn up too.

First 10 11 12 13 14 15 16 Last Page 12 of 33