A little slow out of the blocks but maybe useful to someone anyway:

For lists up to a certain size, doing the arithmetic using whole lists instead of individual elements is faster. On my machine, the first method is _way_ faster on lists with 500 or fewer items, and roughly 10% faster on lists of 10000 items.


global gPointList

on makelist howMany
  gPointList =[]
  repeat with x = 1 to howMany
    gPointList.add(point(random(100),random(100)))
  end repeat
end

on test
  kount = gPointList.count -- The list of known points
  thePoint = point(10,10)  -- the point in question

  ms = the milliseconds
  testlist = []
  repeat with x = 1 to kount
    testList.add(thePoint)
  end repeat
  outlist = gPointList - testList
  now = the milliseconds
  put now - ms

  ms = the milliseconds
  testlist = []
  repeat with x = 1 to kount
    outlist.add(gPointList[x] - thePoint)
  end repeat
  now = the milliseconds
  put now - ms
end


 - Carl
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
lingo-l@penworks.com  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to