function for greatest object in list less than or equal to a value
Randy Hengst
iowahengst at mac.com
Mon Oct 12 12:26:44 EDT 2015
I realize this isn’t written as a function, but what about doing the sort first?
on getMaxLessThan tList,maxVal
sort items of tList descending
repeat for each item theDigitToCheck in tList
if theDigitToCheck < maxVal then
answer "found it" && theDigitToCheck
exit repeat
end if
end repeat
end getMaxLessThan
be well,
randy
Randy Hengst
www.classroomFocusedSoftware.com
> On Oct 12, 2015, at 10:26 AM, J. Landman Gay <jacque at hyperactivesw.com> wrote:
>
> Oops, I missed that. You're right.
>
> On October 12, 2015 8:35:04 AM CDT, dunbarx at aol.com wrote:
>> Jacque,
>>
>>
>> My gadget adds the index in a parameter to the function. if it already
>> exists in the list, the addition is superfluous, but harmless.
>>
>>
>> Craig
>>
>>
>>
>> -----Original Message-----
>> From: J. Landman Gay <jacque at hyperactivesw.com>
>> To: How to use LiveCode <use-livecode at lists.runrev.com>
>> 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, dunbarx at 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 list. The
>> example list was: "1,3,4,7,9" and the target limit was 5.
>>
>> I
>> couldn't see a way that avoids looping through all the values.
>>
>> --
>>
>> Jacqueline Landman Gay | jacque at hyperactivesw.com
>> HyperActive
>> Software |
>> http://www.hyperactivesw.com
>>
>> _______________________________________________
>> use-livecode
>> mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe,
>> unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> --
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list