Ilya Zakharevich on Mon, 27 Nov 2023 04:48:37 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: #matr~ vs ##matr (and: arity, questenian and !!) |
On Fri, Feb 05, 2021 at 05:54:48AM -0800, Ilya Zakharevich wrote: > On Fri, Feb 05, 2021 at 05:46:43AM -0800, Ilya Zakharevich wrote: > > Is not it desirable to implement ##matr as an (optimized) synonym for #matr~? > > > > If the answer to the second question is positive, then one can maybe > > improve things by returning a special value (such as -1) for scalars… > > Well, to get things yet simpler, one can make ###x to return 0 for > scalars, 1 for vectors/lists and 2 for matrices. Taking all these things together, I think that in the best of the worlds one would have these: #mattr~ optimized in the compiler to (an equivalent to) (matsize(mattr))[1] ##object return “the arity” of the object: 2/1/0 for matrices/vectors/scalars (and maybe -1 for the “tricky” cases, when/if an object may be used as a scalar AND as a vector/matrix/etc.). Hope this helps, Ilya P.S. I wonder what is the purpose of implementing extra-obscure¹⁾ num# when PARI cannot even calculate 3!! right?! ¹⁾ IIRC, Steinhaus has been denoting this as num? (“questenian”???). If so, then num?? would have been more appropriate in PARI.