Am 3 Jun 2006 um 16:36 hat Henry Lenzi geschrieben:
> Hi --
>
> Here's my problem: I want to make a list made of huge numbers. Then,
> I want to sort it. I don't want maxima to expand powers (I want it too
> keep exponential notation, for readability.) Is ther a way?
>
The answer depends on what you want to do with your list after sorting. Just two
possibilities:
(%i1) [[10^5,"10^5"],[2^8,"2^8"],[2^32,"2^32"]]$
(%i2) sort(%)$
(%i3) map(second,%);
(%o3) [2^8, 10^5, 2^32]
In this case the answer is a list of strings. An evaluation is now possible with mapping
function 'parse_string' from /share/contrib/eval_string.lisp onto every element, but this
would expand the powers.
Another posssibility is quoting the exponentiation operator. As far as I know, quoting
operators is not available at the moment. I would like to see this. But here is a workaround.
I define a quoted exponentiation.
(%i4) :lisp (defun $exptq (x y) `((mexpt simp) ,x ,y))
$EXPTQ
(%i4) [[10^5,exptq(10,5)],[2^8,exptq(2,8)],[2^32,exptq(2,32)]]$
(%i5) sort(%)$
(%i6) map(second,%);
8 5 32
(%o6) [2 , 10 , 2 ]
Here the answer is a list of unevaluated powers.
You can simply evaluate them with a double single quote (two typed single quotes) ...
(%i7) ''%;
(%o7) [256, 100000, 4294967296]
... or with ev(%);
Volker