Joe Riel

9615 Reputation

23 Badges

19 years, 203 days

MaplePrimes Activity


These are Posts that have been published by Joe Riel

Maple's foldl and foldr procedures provide a convenient means to generate an n-ary function from a binary operator. For example, from another thread, one can use foldl to create an n-ary and procedure from Maple's binary `and` function:

Hmmm. How did eTwqgQegPG manage to accumulate 246 points in less than 2 days? Without posting anything?
In a previous blog entry I described a novel method, proposed by Robert Israel, for sorting a list of lists of small positive integers, specifically those less than 256. It is significantly faster than the usual method. Roman Pearce responded with a method for rapidly sorting listlists of integers (a listlist is a list of sublists with identical number of elements), regardless of size. While not as fast as Robert's technique, it, too, is significantly faster than the usual method and has no restriction on integer size.
A poster on the usenet group comp.soft-sys.math.maple asked how to do the following more simply:
A:={ { [1,2],[3,4] } , { [5,6],[7,8] } }:
map(x->map(y->map(f,y),x),A);

       {{[f(1), f(2)], [f(3), f(4)]}, {[f(5), f(6)], [f(7), f(8)]}}
As has been discussed here recently, this can be readily done using evalindets. For example,
evalindets(A, list, integer, f);
       {{[f(3), f(4)], [f(1), f(2)]}, {[f(5), f(6)], [f(7), f(8)]}}
John Fredsted asks whether there is a built-in method in Maple for lexically sorting a list of lists of small positive integers. There is not, however, Robert Israel provided two methods for accomplishing the task. The first uses the standard technique for extending Maple's sort procedure, that is, assigning a boolean-valued binary function and passing it to sort. The second method that Robert provided is ingenious. Here it is, in full,
Ls:= map(convert,L,bytes):
Ls:= sort(Ls, lexorder):
map(convert,Ls,bytes);

It converts each list into a string, sorts the strings, then converts the strings back to lists. This method is significantly faster than the previous. It does, however, have a limitation; it can only operate on lists with positive integers in the range 1..255. While that limitation was suitable for the original poster's application, that will not always be the case.

First 6 7 8 9 10 11 12 Last Page 8 of 16