|
From: Stavros M. <mac...@gm...> - 2025-01-01 17:49:28
|
By the way, the equivalency of *"op"(a,b) *and *a op b *a (where *op *is defined as *infix*) are covered in the Maxima documentation section *Introduction to Operators <https://maxima.sourceforge.io/docs/manual/maxima_35.html>, *with examples. User-defined operators and built-in operators work in exactly the same way. I suppose we could give an example of, say, *"!"(3) == 3!*. An example of user-defined operators is the following. Note that the explicit function call "dd" (a) is equivalent to dd a, likewise "<-" (a, b) is equivalent to a <- b. Note also that the functions "dd" and "<-" are undefined in this example. (%i1) prefix ("dd"); (%o1) dd (%i2) dd a; (%o2) dd a (%i3) "dd" (a); (%o3) dd a (%i4) infix ("<-"); (%o4) <- (%i5) a <- dd b; (%o5) a <- dd b (%i6) "<-" (a, "dd" (b)); (%o6) a <- dd b There is also an example of an operator being used as a functional argument in the documentation for <https://maxima.sourceforge.io/docs/manual/maxima_21.html#:~:text=applied%20to%20built>*lreduce <https://maxima.sourceforge.io/docs/manual/maxima_21.html#:~:text=applied%20to%20built>* . (%i1) lreduce ("^", args ({a, b, c, d})); b c d (%o1) ((a ) ) (%i2) lreduce ("/", args ({a, b, c, d})); a (%o2) ----- b c d (Not sure why it writes* args ({a, b, c, d})* instead of simply *[a, b, c, d] *.) Where else would it be useful to document this equivalence? -s On Mon, Nov 25, 2024 at 6:34 PM Stavros Macrakis <mac...@gm...> wrote: > As far as Maxima is concerned, *"+" *is a function like any other. You > can write *f(3,4)*, so you can write *"+"(3,4)*. But the parser also > allows you to use the more conventional and convenient infix form. > Technically, this is not Polish notation, which allows only fixed-arity > operations and therefore can dispense with parentheses, e.g., *"+"(a,"*"(b,c),d) > *would be written as *+a+*bcd *in Polish notation, or *abc*+d+* in > reverse Polish notation (found in Forth and some calculators). > > Using *"+"* etc. as function names is very useful in many parts of > Maxima, e.g., *xreduce("+", list)* adds the elements of the list and *is(op(ex)="+") > *determines whether the expression is in the form of a sum. It is rarely > useful to write things as *"+"(a,b) *for a fixed number of arguments, > though. > > Re *?mplus*, that will certainly work, but it's intended to be internal. > > -s > > On Mon, Nov 25, 2024 at 6:03 PM Richard Fateman <fa...@gm...> wrote: > >> There are many features of Maxima that are not documented, and (in my >> opinion) >> some elaborately documented features that are of very little interest, so >> it is hard >> to make a judgment. However, it is also possible to write >> ?mplus(a,b) to produce a+b. Similarly, ?mtimes, ?mexpt, ?mquotient. >> >> I don't see much point to "["(a,b,c) since [a,b,c] is shorter. >> ?mlist(a,b,c) also works but >> is even longer. >> Have fun! >> RJF >> >> >> On Mon, Nov 25, 2024 at 2:54 PM El Observatorio De Matemática < >> obs...@gm...> wrote: >> >>> Hi list, >>> >>> Through an old Macsyma book or article, I learned about a way to pass >>> expressions in a polish-like form. Here are constructed examples: >>> >>> >>> "+"("^"(y,4),"-"("*"(4,x,"^"(y,3))),"*"(6,"^"(x,2),"^"(y,2)),"-"("*"(4,"^"(x,3),y)),"^"(x,4)); >>> >>> "["(2,5,9,4); >>> >>> "+"("*"(2,a,sin(x)),"^"(%e,x)); >>> >>> several kinds of expressions can be put in a polish-like form. >>> >>> The question is, should polish-like expressions be documented? >>> >>> FWIW, and best regards >>> -- >>> https://github.com/Observatorio-de-Matematica >>> _______________________________________________ >>> Maxima-discuss mailing list >>> Max...@li... >>> https://lists.sourceforge.net/lists/listinfo/maxima-discuss >>> >> _______________________________________________ >> Maxima-discuss mailing list >> Max...@li... >> https://lists.sourceforge.net/lists/listinfo/maxima-discuss >> > |