function for greatest object in list less than or equal to a value

hh hh at livecode.org
Tue Oct 13 11:06:47 EDT 2015


@P.T.B

The average time needed is (testing gave me a break ...)

[c] LC 8.0.0-dp7
repeat-PMB	3.794
repeat-GC	1.475  <- fastest
repeat-hh      1165.0 <- :-(  No difference to LC 7.1.0!
sort-GC   	7.240

I have indeed data strings of the tested size (10-15 MByte).
Advanced statistical analysis without arrays is close to useless.
And LC > 6 has the useful option to split and combine by
delimiters of length > 1.

Is the library 'com.livecode.foreign' a target of hope?

p.s. Your HTML5-link from 'This Week in Livecode' forces me to
improve that test. What a trick!  ;-)

@G.C.
Of course is a large smaller-than-set the worst case for the PMBrepeat.

But meanwhile I think, fully convinced by the tests with LC 7 and 8
(see above) that your 'direct' function greatestLessThanRepeat is the
way to go.

It works also great for smallestGreaterThan (without equality) or both:

-- Here v is the critical value and v1,v2 are starting values
-- for min and max, coming from a pre-knowledge about the data
-- or for example v1=-10^16, v2=10^16
function miniMaxGC L,v,v1,v2
   put v1 into vMax; put v2 into vMin
   repeat for each item i in pList
      if i < v and i > vMax then put i into vMax
      else if i > v and i < vMin then put i into vMin
   end repeat
   return ( vMax, v, vMin )
end miniMaxGC

[Perhaps a switch will be better? Or eliminate at first v by "replace"?]

  




More information about the use-livecode mailing list