Mark E Roberts <M.E.Roberts-CSAI97@cs.bham.ac.uk> writes:
> Date: Thu, 06 May 1999 14:01:40 +0100
>
> Is there a procedure similar to syssort, allowing a user defined
> predicate to sort, but for use on arrays?
>
A quick answer.
Assuming you are referring to a 1-D array (or a vector, which is a
more efficient 1-D array) use datalist to produce a list of items in
the array. Sort the list using syssort, then use either explode
and fill to put the new sorted stuff in the original array, or
create a new array of the same size and fill that.
You can even use sys_grbg_list to reduce garbage collection, but
only if you REALLY know what you are doing (see REF FASTPROCS and
HELP EFFICIENCY).
syssort(datalist(newarray([1 10], procedure x; -x endprocedure)), nonop < ) =>
** [-10 -9 -8 -7 -6 -5 -4 -3 -2 -1]
See REF explode, REF fill
Aaron
===
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (NB: Anti Spam address)
PAPERS: ftp://ftp.cs.bham.ac.uk/pub/groups/cog_affect/0-INDEX.html
|