Jump to content

Extracting (efficiently) a sub-list from a list


jbreard

Recommended Posts

Good morning (evening) everyone,

 

I have a question which will seam basic to you I guess concerning a simple list manipulation.

 

I have a list of the form ((X0 Y0 Z0 T0)  (X1 Y1 Z1 T1)...(Xn Yn Zn Tn)) and I want to extract efficiently a sublist form this list ((Xi Yi Zi Ti)....(Xj Yj Zj Tj)) given that I know the ranges i and j.

 

I know how to do that using a "while" loop and populating a sublist by accessing the elements trough "nth" but that is not very efficient. An other approch could alos be to use a formula using 2 time "member" and "reverse" and "nth" but that is not efficient as well.

 

I have to perform this extraction on a list whose length is about 40 000 and I must perform this extraction about 2000 times. Hence the need for speed...

 

I'm sure that a language like AutoLISP must have efficient ways to do that but I don't see it at the moment.

 

Does anyone as an insight on that matter ? Maybe a basic function that I don't know about ?

 

Thank you very much for your help,

 

Jacques

Link to comment
Share on other sites

Thanks a lot,

 

That is just perfect. I know of course of Lee-Mac's treasure's website but I missed this one :)

 

Have a nice day,

 

Jacques

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...