Re: fastes way to search an array?

2015-05-04 Thread Bob Sneidar
I wrote a couple functions that “flatten” an array into a string in such a way that it can be converted back into an array again when done. Here they are: function altPrintKeys @pArray, theKeyList, pFullData put numtochar(11) into vertTab put numtochar(30) into altCr put the keys of

Re: fastes way to search an array?

2015-05-04 Thread Eric Corbett
Cool function Bob, I always love a good recursive handler. It might be broken when an array element contains more than one word. (Limited testing tho.) Eric On May 4, 2015, at 2:14 PM, Bob Sneidar bobsnei...@iotecdigital.com wrote: I wrote a couple functions that “flatten” an array into a

Re: fastes way to search an array?

2015-05-04 Thread Bob Sneidar
That is in an array key name. Bob S On May 4, 2015, at 14:32 , Bob Sneidar bobsnei...@iotecdigital.commailto:bobsnei...@iotecdigital.com wrote: That may be. I never use multiple words in an array so it would never have occurred to me to test for that. Bob S

Re: fastes way to search an array?

2015-05-04 Thread Bob Sneidar
That may be. I never use multiple words in an array so it would never have occurred to me to test for that. Bob S On May 4, 2015, at 14:30 , Eric Corbett e...@canelasoftware.com wrote: Cool function Bob, I always love a good recursive handler. It might be broken when an array element

AW: fastes way to search an array?

2015-04-24 Thread Tiemo Hollmann TB
any extra commands like filter. Thanks for caring Tiemo -Ursprüngliche Nachricht- Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von Mike Bonner Gesendet: Freitag, 24. April 2015 00:39 An: How to use LiveCode Betreff: Re: fastes way to search an array? Did

Re: fastes way to search an array?

2015-04-23 Thread Mike Bonner
Ah k, so it would be situational. After reading back in the thread some, I suspect the tests would be 2 different strings, so testing for both would be necessary. I was just not grokking the double. Probably just easier to set up a single string and check for it twice. Either way, it runs

Re: fastes way to search an array?

2015-04-23 Thread Mike Bonner
Did some testing out of curiosity, and WOW this is fast. repeat for each key tKey in tArray if tArray[tKey] begins with tSearchString or \ tArray[tKey] contains tSearchString then put tKey return after tResults end if end repeat The only question I have is.. why search for the

Re: fastes way to search an array?

2015-04-23 Thread Jerry Jensen
Actually it may be a bit faster with the two tests if a lot of them match at the beginning. Testing at the beginning (begins with) is a lot faster than spinning through the entire thing (contains), and if the first clause of the OR is satisfied, it won’t execute the second clause. So, maybe.

Re: fastes way to search an array?

2015-04-23 Thread Geoff Canyon
On Wed, Apr 22, 2015 at 6:22 PM, Peter Haworth p...@lcsql.com wrote: Out of interest, I added a test which used combine and filter. It took around 3 times longer than the other two tests. Yeah, I didn't expect this to be competitive except under specific circumstances -- if the filter

AW: fastes way to search an array?

2015-04-23 Thread Tiemo Hollmann TB
Thanks Richard and others for you helpful remarks Tiemo -Ursprüngliche Nachricht- Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von Richard Gaskin Gesendet: Mittwoch, 22. April 2015 18:04 An: use-livecode@lists.runrev.com Betreff: Re: fastes way to search

Re: fastes way to search an array?

2015-04-23 Thread Mark Waddingham
On 2015-04-23 02:15, Richard Gaskin wrote: In fact, given that SearchArray1 includes the extra overhead of extracting the keys and creating a text list from them, if it were faster I'd call it a bug. I think you may have your SearchArray* functions round the wrong way. SearchArray1 is 'direct

Re: fastes way to search an array?

2015-04-23 Thread Mark Waddingham
I have an array with 2 records, where I want to extract all records, which either begins with or contains a search string. From your description I presume your array is of the form: tArray[key_1] = some string tArray[key_2] = some string ... tArray[key_n] = some string From this you want

AW: fastes way to search an array?

2015-04-23 Thread Tiemo Hollmann TB
Mark, thank you for your comments Tiemo -Ursprüngliche Nachricht- Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von Mark Waddingham Gesendet: Donnerstag, 23. April 2015 11:03 An: How to use LiveCode Betreff: Re: fastes way to search an array? I have

Re: fastes way to search an array?

2015-04-22 Thread Richard Gaskin
Tiemo wrote: I have an array with 2 records, where I want to extract all records, which either begins with or contains a search string. Up to now I just loop thru the whole array, do the compare and extract the result records. I wonder, if there is a way to speed up this search? E.g.,

Re: fastes way to search an array?

2015-04-22 Thread Rick Harrison
Hi Tiemo, What is the average and worst time that it takes to search your 20,000 record array now? Are there users other than you involved? Is it worth the time it will take you to optimize the code for the faster execution? Now that you’ve hopefully answered these questions for yourself, and

fastes way to search an array?

2015-04-22 Thread Tiemo Hollmann TB
Hello, I have an array with 2 records, where I want to extract all records, which either begins with or contains a search string. Up to now I just loop thru the whole array, do the compare and extract the result records. I wonder, if there is a way to speed up this search? E.g., does it

Re: fastes way to search an array?

2015-04-22 Thread Rick Harrison
Hi Tiemo, The computer industry changes so quickly now that you won’t have to wait very long for the machines to get faster. Cheers, Rick On Apr 22, 2015, at 11:15 AM, Tiemo Hollmann TB toolb...@kestner.de wrote: Hi Rick, On my new and fast development machine the search is pretty fast

Re: fastes way to search an array?

2015-04-22 Thread Geoff Canyon
One way to do this would be combine the array (or maintain a duplicate copy) and use the filter command to do the search. On Wed, Apr 22, 2015 at 8:44 AM, Rick Harrison harri...@all-auctions.com wrote: Hi Tiemo, What is the average and worst time that it takes to search your 20,000 record

AW: fastes way to search an array?

2015-04-22 Thread Tiemo Hollmann TB
way to search an array? Hi Tiemo, What is the average and worst time that it takes to search your 20,000 record array now? Are there users other than you involved? Is it worth the time it will take you to optimize the code for the faster execution? Now that you’ve hopefully answered

Re: fastes way to search an array?

2015-04-22 Thread Bob Sneidar
Rick Harrison Gesendet: Mittwoch, 22. April 2015 15:44 An: How to use LiveCode Betreff: Re: fastes way to search an array? Hi Tiemo, What is the average and worst time that it takes to search your 20,000 record array now? Are there users other than you involved? Is it worth the time

Re: fastes way to search an array?

2015-04-22 Thread Alex Tweedly
Note the go url- it's intended to be typed into the message box to load the stack into Livecode IDE. On 23/04/2015 00:40, Rick Harrison wrote: Hi Richard, I tried this url in Safari - it didn’t work. Are you sure this is the correct link? Thanks, Rick go url

Re: fastes way to search an array?

2015-04-22 Thread Richard Gaskin
Works in Firefox and Chrome as well. Andre might suggest maybe Safari's broken. :) -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.com

Re: fastes way to search an array?

2015-04-22 Thread Phil Davis
I tried it from the message box - it works. Phil On 4/22/15 4:40 PM, Rick Harrison wrote: Hi Richard, I tried this url in Safari - it didn’t work. Are you sure this is the correct link? Thanks, Rick go url http://fourthworld.net/lc/array_access_speeds.livecode; -- Richard Gaskin

Re: fastes way to search an array?

2015-04-22 Thread Richard Gaskin
Alex Tweedly wrote: On 22/04/2015 23:51, Richard Gaskin wrote: May not be much of a need, though, since traversing arrays with what we have is pretty fast - from my earlier email: go url http://fourthworld.net/lc/array_access_speeds.livecode; ... When I try this with 6.7, I get the

Re: fastes way to search an array?

2015-04-22 Thread Alex Tweedly
On 22/04/2015 23:51, Richard Gaskin wrote: May not be much of a need, though, since traversing arrays with what we have is pretty fast - from my earlier email: go url http://fourthworld.net/lc/array_access_speeds.livecode; And the conclusion within that stack says .. The results here

Re: fastes way to search an array?

2015-04-22 Thread Mike Bonner
I wonder how easy it would be to add an option to arrayencode. It already flattens an array nicely, but not in a searchable way. It would be cool to add an optional argument that still flattens, but doesn't encode. The code to traverse the array is already there, with an option to leave the data

Re: fastes way to search an array?

2015-04-22 Thread Peter Haworth
Out of interest, I added a test which used combine and filter. It took around 3 times longer than the other two tests. Pete lcSQL Software http://www.lcsql.com Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and SQLiteAdmin http://www.lcsql.com/sqliteadmin.html On Wed, Apr 22,

Re: fastes way to search an array?

2015-04-22 Thread Rick Harrison
Hi Richard, I tried this url in Safari - it didn’t work. Are you sure this is the correct link? Thanks, Rick go url http://fourthworld.net/lc/array_access_speeds.livecode; -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the

Re: fastes way to search an array?

2015-04-22 Thread Richard Gaskin
Mike Bonner wrote: I wonder how easy it would be to add an option to arrayencode. It already flattens an array nicely, but not in a searchable way. It would be cool to add an optional argument that still flattens, but doesn't encode. The code to traverse the array is already there, with an

Re: fastes way to search an array?

2015-04-22 Thread Phil Davis
Hi Tiemo, How many levels deep are the array elements you want to search? How many words might each of the searchable array elements contain? How is the array keyed - by sequential number, a preassigned numeric ID, a content description, ...? Would it be worth your time when loading the