On Fri, Oct 16, 2015 at 2:02 PM, wrote:
> Geoff.
>
>
> My original post:
>
>
>
> on mouseUp
> answer findItemLessThanIndex(fld 1,"5")
> end mouseUp
>
> function findItemLessThanIndex tData,tIndex
>put comma & tIndex after tData
>sort items of tData numeric
>return item itemOffset("
emLessThanIndex
Craig
-Original Message-
From: Geoff Canyon
To: How to use LiveCode
Sent: Fri, Oct 16, 2015 12:04 pm
Subject: Re: function for greatest object in list less than or equal to a value
I couldn't find the original code for the offset version, but I took a shot
at
it
I couldn't find the original code for the offset version, but I took a shot
at it and got the following results, with the repeat solution still faster
(in 6.7.3):
Run Count: 10
Test ID: 1 Looking for greatest value < 5
sort 0.920932 48402
repeat 0.33892 48402
PMB 0.337938 4840
Hi.
The param "3" would be added to the list. The sorted list would be:
"2,3,4". When the itemOffset finds the "3", the item just before it would be
"2". That is how it works. To find the item just before itemOffset does.
This is faster than any of the "repeat for each..." variants I have seen h
On Mon, Oct 12, 2015 at 6:35 AM, wrote:
> My gadget adds the index in a parameter to the function. if it already
> exists in the list, the addition is superfluous, but harmless.
>
But if the search list is "2, 4", and the search value is 3, doesn't this
return "3" rather than 2?
--
Dr. Richar
On Mon, Oct 12, 2015 at 4:24 PM, Geoff Canyon wrote:
> function greatestLessThan pList,V
>sort items of pList descending numeric
>sort items of pList by each >= V
>return item 1 of pList
> end greatestLessThan
Something along these lines was what I'm trying to wrap my head around,
w
Peter TB Brett wrote:
On 13/10/2015 15:33, Richard Gaskin wrote:
Peter TB Brett wrote:
> On 13/10/2015 14:42, hh wrote:
>> There is an interesting difference between LC versions 6 and 7.
>>...
>> [a] LC 6.7.7
>> repeat-PMB 0.326 <- fastest
>> repeat-GC 0.350
>> repeat-hh 0.445
>> sort-G
I ran the same code in 7.0.3 and got this:
Run Count: 10
Test ID: 1 Looking for greatest value < 5
sort 9.366217 49338
repeat 1.764816 49338
PMB 4.268512 49338
Test ID: 2 Looking for greatest value < 5
sort 8.5548
repeat 1.534175
PMB 1.494919
Test ID: 3 Looking for greatest
@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 statistica
On 13/10/2015 15:33, Richard Gaskin wrote:
Peter TB Brett wrote:
> On 13/10/2015 14:42, hh wrote:
>> There is an interesting difference between LC versions 6 and 7.
>>...
>> [a] LC 6.7.7
>> repeat-PMB 0.326 <- fastest
>> repeat-GC 0.350
>> repeat-hh 0.445
>> sort-GC 0.985
>>
>> [b] LC
Peter TB Brett wrote:
> On 13/10/2015 14:42, hh wrote:
>> There is an interesting difference between LC versions 6 and 7.
>>...
>> [a] LC 6.7.7
>> repeat-PMB 0.326 <- fastest
>> repeat-GC 0.350
>> repeat-hh 0.445
>> sort-GC 0.985
>>
>> [b] LC 7.1.0
>> repeat-PMB 3.562
>> repeat-GC 1.483 <- fastes
On Tue, Oct 13, 2015 at 4:35 AM, hh wrote:
> function getMaxLessThan tList,maxVal
>repeat for each item i in tList
> if i < maxVal then put i & comma after outList
>end repeat
>return max(outList)
> end getMaxLessThan
>
This returns 0 if there is no valid result, rather than em
Hi Hermann,
There's no array bug -- it's an aspect of its intentional behaviour.
Appending to an element of an array always causes a copy, so you get
O(N^2) complexity.
Please re-test in LiveCode 8.0.0-dp-7, because there are some large
performance optimisations in that release that may affe
Similar things are useful for a very specialized statistical
evaluation I have to do soon, so I tested again with LC 7:
There is an interesting difference between LC versions 6 and 7.
The 'direct way' of GC reveals now as clearly fastest.
Tested with one of GC's 12 MB strings on a Mac mini(i5 2.
Here are a couple of functions that might be useful re timing processes.
-- Peter
Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig
--
function microsecs
put the long seconds into s
set the numberformat to "#.00"
add 0 to s
replace "." with empty in s
On 13/10/2015 02:20, Mike Doub wrote:
Pass by reference and you can eliminate a memcopy on the initial function call.
-= Mike
That *used* to be true - but (unless my memory is playing tricks again
:-), Mark Waddingham said on the list recently that recent (*) versions
of LC use a pointer, an
@Craig
I also found the "sort" method faster than the "repeat" method on
a PPC. On intel, under several OSes, here always won the [1] below.
@Bernd
I didn't include your solution because pre-sorting wastes too
much time. Perhaps sorting could be included in your binary loop?
@Geoff
You could also
39 49879
repeat 0.331764 49879
On Tue, Oct 13, 2015 at 12:07 AM, wrote:
> Geoff.
>
>
> I find this slower than the sort method. By about 30%.
>
>
> Craig
>
>
>
> -Original Message-----
> From: Geoff Canyon
> To: How to use LiveCode
> Sent: Mon, O
305.n4.nabble.com/function-for-greatest-object-in-list-less-than-or-equal-to-a-value-tp4697221p4697349.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url
Geoff.
I find this slower than the sort method. By about 30%.
Craig
-Original Message-
From: Geoff Canyon
To: How to use LiveCode
Sent: Mon, Oct 12, 2015 9:11 pm
Subject: Re: function for greatest object in list less than or equal to a value
Not quite as concise, but this
The first sort is straightforward, and turns "1,2,4,5,6,8,9" into
"9,8,6,5,4,2,1"
The second sort splits that into two groups. The first group is the entries
that fail the test, the second is the entries that pass the test. Since the
test is ">=", 5 passes the test and goes in the second group. Th
Sure, that's always an option for large data calls to functions.
On Mon, Oct 12, 2015 at 9:20 PM, Mike Doub wrote:
> Pass by reference and you can eliminate a memcopy on the initial function
> call.
>
> -= Mike
>
>
>
> On Oct 12, 2015, 9:11 PM, at 9:11 PM, Geoff Canyon
> wrote:
> >Not quite as
On 10/12/2015 6:24 PM, Geoff Canyon wrote:
function greatestLessThan pList,V
sort items of pList descending numeric
sort items of pList by each >= V
return item 1 of pList
end greatestLessThan
Clever. How come it works when V is in the list, when you're asking for
">=" ? Seems lik
Pass by reference and you can eliminate a memcopy on the initial function call.
-= Mike
On Oct 12, 2015, 9:11 PM, at 9:11 PM, Geoff Canyon wrote:
>Not quite as concise, but this function is about 3x faster:
>
>function greatestLessThan pList,V
> put empty into R
> repeat for each item i i
Not quite as concise, but this function is about 3x faster:
function greatestLessThan pList,V
put empty into R
repeat for each item i in pList
if i < V and i > R then put i into R
end repeat
return R
end greatestLessThan
___
use-livecod
function greatestLessThan pList,V
sort items of pList descending numeric
sort items of pList by each >= V
return item 1 of pList
end greatestLessThan
100,000 items, two sorts, and consistently returns in under 0.075 seconds
on my Mac:
on mouseUp
repeat 10
put random(1000
pe of thing. Missing values are no problem but empty items would.
did you benchmark my snippet and yours say on a list of 10 items?
Kind regards
Bernd
--
View this message in context:
http://runtime-revolution.278305.n4.nabble.com/function-for-greatest-object-in-li
[@Bernd: here a PONG to your PING.]
Obviously each list member has to be inspected once for the comparison.
And each "smaller than"-member has to be inspected once again to find
the maximum. There is no other way, this is a math fact.
Here is my solution, that seems to be pretty fast.
-- v is a
Bob Sneidar wrote:
> On Oct 12, 2015, at 10:41 , Richard Gaskin wrote:
>> The choice of tying the ticks to retrace was perhaps a necessity
>> in early Mac OS systems, relying as they did on preemptive
>> multitasking. But that reliance also made it an inexact quantity:
>> by default the vertical
NVM stupid question. I was thinking about the lag older systems would introduce
in the actual clock, and lost sight of the problem.
Bob S
On Oct 12, 2015, at 11:21 , Bob Sneidar
mailto:bobsnei...@iotecdigital.com>> wrote:
So are you sating that if I had a monitor that refreshed at say 120/sec
That is interesting. I was always under the impression that a tick was always
1/60 of a second. It never occurred to me that this was the standard vertical
refresh of the monitors in use at the time.
So are you sating that if I had a monitor that refreshed at say 120/sec, that
there would then
On 2015-10-12 19:56, dunb...@aol.com wrote:
"Sort" is consistently faster, up to 50%. Why "up to"? Try it several
times. As per the other, newer part of this thread, timing based on
such things as "ticks" needs to be run many times to get an accurate
"average" reading. Other system processes come
hings as
"ticks" needs to be run many times to get an accurate "average" reading. Other
system processes come into play, as well as gremlins.
Craig
-Original Message-
From: Peter TB Brett
To: How to use LiveCode
Sent: Mon, Oct 12, 2015 11:23 am
Subject: Re: function f
://runtime-revolution.278305.n4.nabble.com/function-for-greatest-object-in-list-less-than-or-equal-to-a-value-tp4697221p4697273.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Correction - earlier I wrote:
The choice of tying the ticks to retrace was perhaps a necessity in
early Mac OS systems, relying as they did on preemptive multitasking.
That should of course read:
The choice of tying the ticks to retrace was perhaps a necessity in
early Mac OS systems, relying
BNig wrote:
BTW, what is a tick? Is that the imperial gallon of time? Or more a pint, a
fluid ounce?
I do kow that ticks bite and :)
In other programming languages a tick is often a counter within some
larger timer framework.
In HyperTalk it was derived similarly, the default update rate fo
wait for 10 ticks -- 1/6 of a second
>
> No guarantees, did test it though with various lists up to 10 items, but
> what the tick... :)
> My first attempt at something like "binary search" so please be forgiving.
>
> Kind regards
> Bernd
ing like "binary search" so please be forgiving.
Kind regards
Bernd
--
View this message in context:
http://runtime-revolution.278305.n4.nabble.com/function-for-greatest-object-in-list-less-than-or-equal-to-a-value-tp4697221p4697266.html
Sent from the Revol
sage-
>> From: J. Landman Gay
>> To: How to use LiveCode
>> Sent: Mon, Oct 12, 2015 12:07 am
>> Subject: Re: function for greatest object in list less than or equal to
>> a value
>>
>>
>> On 10/11/2015 9:26 PM, dunb...@aol.com wrote:
>>>
;
>-Original Message-
>From: J. Landman Gay
>To: How to use LiveCode
>Sent: Mon, Oct 12, 2015 12:07 am
>Subject: Re: function for greatest object in list less than or equal to
>a value
>
>
>On 10/11/2015 9:26 PM, dunb...@aol.com wrote:
>> function fi
On 12/10/2015 15:24, dunb...@aol.com wrote:
I made a test between the "sort" method and the "repeat for each". For a list of about
100,000 items, sort finds the max value in 33 ticks, and "repeat" takes 50 ticks.
This seems logical to me, since lower level operations are used in "sort" as opp
to "repeat" even though we all know how fast "repeat for each" is.
Craig
-Original Message-
From: Peter TB Brett
To: How to use LiveCode
Sent: Mon, Oct 12, 2015 4:55 am
Subject: Re: function for greatest object in list less than or equal to a value
On 12/10/2
object in list less than or equal to a value
On 10/11/2015 9:26 PM, dunb...@aol.com wrote:
> function findItemLessThanIndex
tData,tIndex
> put comma & tIndex after tData
> sort items of tData
numeric
> return item itemOffset("5",tData) -1 of tData
>
On 12/10/2015 03:26, Peter M. Brigham wrote:
function getMaxLessThan tList,maxVal
repeat for each item i in tList
if i < maxVal then put i & comma after outList
end repeat
return max(item 1 to -1 of outList)
end getMaxLessThan
This should be slightly faster, because it only
On 10/11/2015 9:26 PM, dunb...@aol.com wrote:
function findItemLessThanIndex tData,tIndex
put comma & tIndex after tData
sort items of tData numeric
return item itemOffset("5",tData) -1 of tData
end findItemLessThanIndex
I thought of that too, but it fails if tIndex isn't in the li
Index after tData
sort items of tData numeric
return item itemOffset("5",tData) -1 of tData
end findItemLessThanIndex
-Original Message-
From: Dr. Hawkins
To: How to use LiveCode
Sent: Sun, Oct 11, 2015 12:16 pm
Subject: function for greatest object in list less than or
function getMaxLessThan tList,maxVal
repeat for each item i in tList
if i < maxVal then put i & comma after outList
end repeat
return max(item 1 to -1 of outList)
end getMaxLessThan
Simple and fast.
-- Peter
Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig
On Oct
It would be nice to have an intrinsic for this, but I just read the entire
function list . . .
I need to find the largest number in a list which is smaller than a
specified value.
e.g., for the list "1,3,4,7,9" and 5, the largest such value would be 4.
In a spreadsheet, I could use use vlookup()
48 matches
Mail list logo