Question: How are the two spellings colour and colour handled in procedures

This question is related to the Question Alternative Argument spelling in a procedure

I have used "colour" as my spelling on optional inputs to procedures in my package.  How can I also handle the alternative spelling "color"?  
 

restart

 

coltest:=proc(c)
  if c="b" then return 1
   elif c="r" then return 2
   elif c="g" then return 3
  end if;
end proc:

 

foo:=proc(a,{colour:="b"})
local COL;
   COL:=coltest(colour);
if COL=1 then return a
  elif COL=2 then return a^2
  elif COL=3 then return a^3
  else error `wrong colour`;
end if ;
end proc:

 

foo(3,colour="r")

9

(1)

foo(2,colour="p")

Error, (in foo) wrong colour

 
 

 

Download 2024-03-21_Q_colour_or_color.mw

Please Wait...