Re: Efficiency of arrays in LISP
- From: Barry Margolin <barmar@xxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 00:20:13 -0500
In article <1162178572.119981.264450@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"robinganemccalla@xxxxxxxxx" <robinganemccalla@xxxxxxxxx> wrote:
I have a list of data that I'm going to need to remove elements from,
and select elements from randomly. I am wondering the array functions
in common lisp would be more effective (in terms of execution time)
then using remove to remove and creating a loop that takes the car if
iterations has reached the random number, and recursively calls itself
on the cdr with a greater value of iterations otherwise. Coding
complexity is not an issue.
Arrays tend to be more efficient than lists if you need to do lots of
random access, but don't need to insert/remove very often. The latter
operations require shifting all the following entries up/down.
Lists are efficient for sequential access and inserting/deleting,
because these can be done simply by updating a couple of CDR slots.
There's not really a single data structure that's likely to be optimal
for all operations. That's why we have several different collection
types -- you get to choose which one fits your needs best.
--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.
- References:
- Efficiency of arrays in LISP
- From: robinganemccalla@xxxxxxxxx
- Efficiency of arrays in LISP
- Prev by Date: Re: [OT] How do you read usenet news (c.l.l of course!)
- Next by Date: Re: Using "internal" macros of a CL implementation
- Previous by thread: Re: Efficiency of arrays in LISP
- Next by thread: Re: Efficiency of arrays in LISP
- Index(es):