to find the first numeric line?

dunbarx at aol.com dunbarx at aol.com
Thu Jan 31 13:37:03 EST 2013


Hi.


I tried this with a list "temp" of 24,000 lines. Takes about half a second:




on mouseup
    sort temp numeric
   put 0 into tCounter
   repeat for each line tLine in temp
      add 1 to tCounter
      if char 1 of tLine is an integer then
         exit repeat
      end if
   end repeat
   answer tLine && tCounter 
end mouseup





Craig



-----Original Message-----
From: Tiemo Hollmann TB <toolbook at kestner.de>
To: 'How to use LiveCode' <use-livecode at lists.runrev.com>
Sent: Thu, Jan 31, 2013 1:13 pm
Subject: AW: to find the first numeric line?


Its about 20,000 lines.
I have made it with cutting into halves, which works ok. Perhaps I give it a
timestamp test compared to just looping through.
Tiemo

> -----Ursprüngliche Nachricht-----
> Von: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] Im
Auftrag
> von dunbarx at aol.com
> Gesendet: Donnerstag, 31. Januar 2013 18:56
> An: use-livecode at lists.runrev.com
> Betreff: Re: to find the first numeric line?
> 
> Hi.
> 
> 
> If you sort your alphanumeric list, you will, of course, already know that
> the alphas sort before the digits, so the first digit will be down a bit.
> 
> 
> 
> But how long is that list? After sorting, if you loop through using the
> "repeat for each..." variant and exit accordingly, I cannot imagine that
it
> would take more than an instant to find the first digital char. Old
> fashioned but trusty.
> 
> 
> I have done binary searches, splitting data in halves as you go so that
you
> cut down processing time, mainly finding stuff in long HC datasets.
> 
> 
> Craig Newman
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> 
> From: Tiemo Hollmann TB <toolbook at kestner.de>
> To: 'How to use LiveCode' <use-livecode at lists.runrev.com>
> Sent: Thu, Jan 31, 2013 11:54 am
> Subject: to find the first numeric line?
> 
> 
> Hello,
> 
> I have a list with alphanumeric and numeric content. After sorting numeric
> I would like to find the first line with a numeric first char. (the non
> numeric lines before can contain also numeric chars). I would like to have
> a kind of lineoffset(isNumber(first char.),list,), but that's not
prebuilt.
> 
> What would be the fastest or most straight forward way to look up such a
> list? Just looping through? Testing the first char every half of the list
> in a loop? Or is there a function I don't think of?
> 
> Thanks for any pointers
> 
> Tiemo
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 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


_______________________________________________
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