Obviously, Plus[a,b] is given by Mathematica but say I have a package and I want to name a function Plus[a,b]. How can I go about making a new function without overwriting the original function Plus[a,b] given from System.
I figured it might be something like this:
BeginPackage["Test`"]
Test`Plus::usage = "Plus[a_,b_] gives..."
(* function defs *)
Test`Plus[a_,b_] := ...
EndPackage[]
Or maybe it has something to do with Unprotect[]? Ideally, I could still type in Plus[a,b] and make use of the system function but I could also type in
Test`Plus[a,b]
to make use of the new Plus function from the package. Thanks
EDIT: in response to Marius Ladegård Meyer Is this what you are suggesting I do?
BeginPackage["Test`"]
Plus::usage = "asdf"
Begin["Private"]
Plus[a_,b_] := adfasf
End[]
EndPackage[]
And then I can use Test`Plus?
Begin/EndandBeginPackage/EndPackageare the way to go here. UsingUnprotecton such a central function asPlusis an extremely bad idea, since it will modify a huge number of other (behind the scenes) Mathematica functions. – Marius Ladegård Meyer Jun 25 '20 at 19:13Begin["`Private`"]or something? – Brandon Jun 25 '20 at 19:15Plus. – QuantumDot Jun 25 '20 at 20:27