|
From: Barton W. <wi...@un...> - 2022-07-31 23:30:00
|
> What is the motivation for these functions? Is it to make life easier for beginners?
I was mostly thinking about making things easier for me. Regardless of the setting of inflag, isn’t it nicer to write
block([inflag : true], if plusp(e) then (XXX) else YYY
than
if not mapatom(e) and inpart(e,0) = “+” then (XXX) else YYY ?
Sure we could have sqrtp, cosinep, …, and hypergeometricp, but surely plusp, timesp, and exptp cover the most needed cases.
--Barton
From: Stavros Macrakis<mailto:mac...@al...>
Sent: Sunday, July 31, 2022 5:31 PM
To: Barton Willis<mailto:wi...@un...>
Cc: max...@li...<mailto:max...@li...>
Subject: Re: [Maxima-discuss] Maxima functions for plusp, timesp, and exptp in src?
Non-NU Email
What is the motivation for these functions? Is it to make life easier for beginners? I think it's a false simplicity. All in all, I think it's generally better for users who want to manipulate expressions programmatically to stick with inflag=true, for exactly the reasons that Maxima uses its internal representation: simplicity and consistency. part is good for interactive use, but a mess for programmatic manipulation.
Details:
* You also need quotientp and (unary) minusp (assuming you're not binding inflag to true)
* What do you want minusp to do for negative numbers? They are mapatoms, but have part/0 = "-" (but part/0 is an error with inflag=true)
* What do you want quotientp to do for rational numbers? They are mapatoms, but have part/0 = "/" (regardless of inflag).
* If you really want to be consistent with part (which is arguably helpful for naive users):
* you'll also need sqrtp (unless you bind sqrtdispflag to false)
* Note that even with inpart=false, part is not fully consistent with the displayed form: op(a-b) is "+", not "-"
* Oh, and the order of args(x-y) depends on negsumdispflag.
* Users still need to understand mapatom for cases like op(ex)='sin
* The functions' behavior depends on the global setting of inflag and %edispflag -- is that your intent?
* They modify the global value of piece -- that means that mixing them with part is problematic
-s
On Sun, Jul 31, 2022 at 2:32 PM Barton Willis via Maxima-discuss <max...@li...<mailto:max...@li...>> wrote:
Would these functions be worthy additions to /src?
(defmfun $timesp (x) (and (not ($mapatom x)) (equal ($part x 0) "*")))
(defmfun $plusp (x) (and (not ($mapatom x)) (equal ($part x 0) "+")))
(defmfun $exptp (x) (and (not ($mapatom x)) (equal ($part x 0) "^")))
Or should they be defined differently? I think we’ve talked about this before.
Instead of ($part x 0), we could call mpart.
--Barton
_______________________________________________
Maxima-discuss mailing list
Max...@li...<mailto:Max...@li...>
https://lists.sourceforge.net/lists/listinfo/maxima-discuss<https://urldefense.com/v3/__https:/lists.sourceforge.net/lists/listinfo/maxima-discuss__;!!PvXuogZ4sRB2p-tU!Cn8i2pF8kddrXIGKjtBMkYLZW3qkjgc_PoxjGCa5LXidAP-OSbXuB55ejYQbEIE8MHP-oyL0LZPZTeQf_19w$>
|