On Thu, 11 Apr 2019, Sven Schreiber wrote:
> I'm thinking: would it be worthwhile to add this to the
"extra" package?
What's the use case, by the way?
I'm using aggregate() on a string-valued variable and I'd like to be able
to sort the results alphabetically.
Speaking about arrays and the extra package: I don't want to
hijack your
thread, but I've thought that a function would be useful that takes an
array argument and applies some operation (another function)
automatically to all elements of the array.
Something like this, you mean?
<hansl>
function matrices apply(const matrices A, string op)
n = nelem(A)
matrices ret = array(n)
loop i = 1 .. n --quiet
ret[i] = feval(op, A[i])
endloop
return ret
end function
matrices A = defarray(I(3), {2,1;1,2})
eval A[1]
eval A[2]
B = apply(A, "inv")
eval B[1]
eval B[2]
C = apply(A, "det")
eval C[1]
eval C[2]
<hansl>
That'd be nice to have as a native funciton, so that we don't have to
write a separate function for every array type we have (unless we find a
mechanism for having "array" as a function argument type).
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------