How to create a new data type: set?

You are right, I had made an assumption without thorough testing.

Now about the processing times of arrays vs. linked lists: I ran some tests on my system for lists of 10,000 items; it turns out that for many operations arrays are about the same speed as linked lists (e.g. KEEP, MAP, SORT), whereas they are considerably faster for e.g. creating a list item by item (iterative ADD vs. recursive IN FRONT OF), LENGTH, and REVERSE. With COMBINE the difference was almost unbelievable: arrays are over 100 times faster than linked lists, I can’t think of a good explanation.

Updates

  • The differences in processing times for COMBINE and LENGTH get even worse for lists of 100,000 items. And I haven’t detected any difference to the advantage of linked lists yet.
  • APPEND is also very much slower for linked lists. (Btw. I had to take APPEND out of the test set eventually because of a stack size issue)
  • I wasn’t able to measure accurate processing times for ADD, INSERT etc., because I think after each single operation the list is apparently converted to an array anyway.
  • I also tried a cdr-coded list (5,000 recursive IN FRONT OF’s an array [5,000]). Processing times were roughly the same as those for a linked list, so I don’t think a warning would be necessary.

https://snap.berkeley.edu/snap/snap.html#present:Username=qw23&ProjectName=Speed%20test%20array%20vs.%20linked%20list

Thanks for the test, which I'll look at after the meeting I'm about to have!