Re: How to use an array to solve the following...

2012-02-22 Thread Kay C Lan
On Tue, Feb 21, 2012 at 11:16 PM, Geoff Canyon Rev wrote: > but > I've been fooled by the near-infinite speed of repeat for each too many > times to count. > > Haven't we all. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this

Re: How to use an array to solve the following...

2012-02-21 Thread Geoff Canyon Rev
As Richard said, the engine is smart enough to avoid this pitfall. So no, it's perfectly fine to say repeat for each line x in the keys of array y even if the list of keys is large. On Tue, Feb 21, 2012 at 12:03 PM, Bob Sneidar wrote: > Repeat for each line x in the keys of array y would seem

Re: How to use an array to solve the following...

2012-02-21 Thread Bob Sneidar
You are probably right, I imagined in my mind that when the engine parses the chunk, it had to already be in memory, as in a variable or array. Since the thing being parsed was a statement that evaluated to something, it seemed that the engine would have nothing in existence to parse to begin wi

Re: How to use an array to solve the following...

2012-02-21 Thread Richard Gaskin
Bob Sneidar wrote: > Repeat for each line x in the keys of array y would seem at a glance > to have to reevaluate the keys of each time through the loop, > wouldn't it? You must mean you get the keys first in a variable and > then use that. If I understand how the engine treats that, it seems t

Re: How to use an array to solve the following...

2012-02-21 Thread Bob Sneidar
Take for example retrieving a large data set from an SQL db. You can retrieve it as a cursor, and array or a string. Cursors are read only and I don't see the advantage of working with them. That leaves only arrays and strings. So if you *can* get the data as an array, and sorting is not an issu

Re: How to use an array to solve the following...

2012-02-21 Thread Bob Sneidar
Even with repeat for each line, the chunk has to be parsed in memory for returns before proceeding. An array is by nature already parsed. As has been discussed before, the repeat for each command is so fast because it parses the memory used by the chunk, creating a list of pointers (forgive me i

Re: How to use an array to solve the following...

2012-02-21 Thread Richard Gaskin
Pete wrote: Interesting, and it kinda makes sense. For elements, there's no positioning required like with lines/words/item, just a case of cycling through the keys - which is what "repeat for each line in the keys of does I suppose. As with most things in computing, the truly optimal soluti

Re: How to use an array to solve the following...

2012-02-21 Thread Geoff Canyon Rev
On Tue, Feb 21, 2012 at 8:36 AM, Glen Bojsza wrote: > The good news is that the lists may grow as high as 1,000,000 lines and are > as little as 30,000. > 1,000,000 lines is pretty big. If you're guaranteed to be working on a recent machine, then perhaps it would be okay. But that's certainly pu

Re: How to use an array to solve the following...

2012-02-21 Thread Geoff Canyon Rev
On Tue, Feb 21, 2012 at 3:52 AM, Kay C Lan wrote: > repeat for each line L in the keys of yourArray > if L > 20 then > put L & cr after R > if L > 60 then >exit repeat > end if > end if > end repeat > > Don't waste cyling through lines you do

Re: How to use an array to solve the following...

2012-02-21 Thread Glen Bojsza
Once the final list has been made it could have up to 10 ?t columns but the query is only for the lines identified as start and end based on the first column which is xs. There would be no other queries involving the data in the ?t columns the whole line that meets the xs query is moved to a new l

Re: How to use an array to solve the following...

2012-02-21 Thread Kay C Lan
On Tue, Feb 21, 2012 at 4:29 PM, Glen Bojsza wrote: > > For example a user wants an starting xs value of 10 and an ending xs value > of 40 I think that if the keys are sequential (the keys being the first > column - xs) then it would be a fast solution using arrays since you should > be able to d

Re: How to use an array to solve the following...

2012-02-21 Thread Glen Bojsza
Then repeat for is King in Livecode! thanks for everyone's feedback . On Tue, Feb 21, 2012 at 2:52 AM, Kay C Lan wrote: > Glen, > > Look at my test results more closely: > > Finding the 1st item of the 1st line using direct reference = 3ms > Finding the last item of the last line using direct r

Re: How to use an array to solve the following...

2012-02-21 Thread Kay C Lan
Glen, Look at my test results more closely: Finding the 1st item of the 1st line using direct reference = 3ms Finding the last item of the last line using direct reference = 440294ms Finding the -1 item of the 1st line using direct reference = 5ms Finding the -1 item of the -1 line using direct r

Re: How to use an array to solve the following...

2012-02-21 Thread Glen Bojsza
I was thinking more along the lines (no pun intended) of - find line number of starting value (for example line 578 ) - find line line number of ending value (for example 12125) put lines 578 to 12125 into results Can this be done verses looping through each line since we know the xs column is

Re: How to use an array to solve the following...

2012-02-21 Thread Kay C Lan
On Tue, Feb 21, 2012 at 4:29 PM, Glen Bojsza wrote: > Or will Kay prove it to be faster > with just lists :-) > > Already proven. I agree with Geoff. For the data example you have provided and the queries you are suggesting, LC can easily handle it using repeat for each line and an if statement a

Re: How to use an array to solve the following...

2012-02-21 Thread Kay C Lan
On Tue, Feb 21, 2012 at 2:09 PM, Dick Kriesel wrote: > On Feb 20, 2012, at 9:37 PM, Kay C Lan wrote: > > > Anyone want to test the speed of finding data in a 100 line variable > > using char -1 of word -1 of item -1 of line -1? > > Hi, Kay. Sure. How do I get the script? > > I'd guess that

Re: How to use an array to solve the following...

2012-02-21 Thread Geoff Canyon Rev
Depends on how big the list is. Unless there's a faster method than the one I used (or you're using slower hardware than I am), you should be okay up to about 100,000 rows using something like: repeat for each line L in the keys of yourArray if L > 20 and L < 60 then put L & cr after R

Re: How to use an array to solve the following...

2012-02-21 Thread Glen Bojsza
Sorry got caught up on an issue... So far things look very fast and seem to give the results I need (will confirm as I use larger data sets that have a known answer). But this does bring up a question and doing more than planned with the final lists... If the final list is kept in sequential ord

Re: How to use an array to solve the following...

2012-02-20 Thread Geoff Canyon Rev
You can get away with straight text for small data sets, but I would never suggest using a single variable and line references for random access on anything more than a few tens of thousands of lines -- although I will point out that in your test, even working with a million lines meant a worst cas

Re: How to use an array to solve the following...

2012-02-20 Thread Dick Kriesel
On Feb 20, 2012, at 9:37 PM, Kay C Lan wrote: > Anyone want to test the speed of finding data in a 100 line variable > using char -1 of word -1 of item -1 of line -1? Hi, Kay. Sure. How do I get the script? I'd guess that almost all the time goes into the line -1, and within that line the

Re: How to use an array to solve the following...

2012-02-20 Thread Kay C Lan
On Tue, Feb 21, 2012 at 10:20 AM, Geoff Canyon Rev wrote: > For items, lines, and words, using > "item/line/word of myContainer" gets worse the larger the container is. For > character and with arrays, it doesn't. > Excellent rules of thumb, though there is a caveat to all this. Unfortunately I

Re: How to use an array to solve the following...

2012-02-20 Thread Pete
Interesting, and it kinda makes sense. For elements, there's no positioning required like with lines/words/item, just a case of cycling through the keys - which is what "repeat for each line in the keys of does I suppose. Pete On Mon, Feb 20, 2012 at 6:20 PM, Geoff Canyon Rev wrote: > Certainl

Re: How to use an array to solve the following...

2012-02-20 Thread Geoff Canyon Rev
Certainly correct, but there is not the tremendous performance advantage to using "for each element in..." For items, lines, and words, using "item/line/word of myContainer" gets worse the larger the container is. For character and with arrays, it doesn't. In my quick testing here, there's just abo

Re: How to use an array to solve the following...

2012-02-20 Thread mikedoub
...@lists.runrev.com Date: Mon, 20 Feb 2012 13:59:48 To: How to use LiveCode Reply-To: How to use LiveCode Subject: Re: How to use an array to solve the following... I tend to use for each line in the keys also, mainly because element returns the contents of the array and I often find myself nee

Re: How to use an array to solve the following...

2012-02-20 Thread Pete
Rogers Wireless Network > > -Original Message- > From: Bob Sneidar > Sender: use-livecode-boun...@lists.runrev.com > Date: Mon, 20 Feb 2012 13:02:12 > To: How to use LiveCode > Reply-To: How to use LiveCode > Subject: Re: How to use an array to solve the following... &

Re: How to use an array to solve the following...

2012-02-20 Thread Bob Sneidar
ON mouseUp pMouseBtnNo put the dgData of group "dgTableData" into theDataA REPEAT FOR each element theRecordA in theDataA add 1 to theItemNum put theRecordA["reservationid"] into item theItemNum of theReservationList END REPEAT put theReservationList END mouseUp I

Re: How to use an array to solve the following...

2012-02-20 Thread mikedoub
13:02:12 To: How to use LiveCode Reply-To: How to use LiveCode Subject: Re: How to use an array to solve the following... Also each element in Bob On Feb 20, 2012, at 10:34 AM, gcanyon+rev wrote: > any time you find yourself writing: > > repeat with i = 1 to the number of lines|wo

Re: How to use an array to solve the following...

2012-02-20 Thread Bob Sneidar
Also each element in Bob On Feb 20, 2012, at 10:34 AM, gcanyon+rev wrote: > any time you find yourself writing: > > repeat with i = 1 to the number of lines|words|items of someContainer > > stop. Rewrite it as: > > repeat for each line|word|item in someContainer __

Re: How to use an array to solve the following...

2012-02-20 Thread gcanyon+rev
On Feb 19, 2012, at 10:42 PM, dunb...@aol.com wrote: > Kay's is much faster than mine. Don't worry about it, it happens to just about every person who's had experience with HyperCard when they come over to LiveCode: the "repeat for each" aha! moment: any time you find yourself writing: repeat

Re: How to use an array to solve the following...

2012-02-19 Thread gcanyon+rev
On Feb 19, 2012, at 8:47 PM, Kay C Lan wrote: > I'm sure others will now improve on that. I doubt it. You're using repeat for each in a sensible way, and there's rarely something faster than that. If you really wanted to tighten up the repeat, you could do something like this, but I doubt tha

Re: How to use an array to solve the following...

2012-02-19 Thread Kay C Lan
On Mon, Feb 20, 2012 at 10:47 AM, Glen Bojsza wrote: > > The biggest picture would be having 10 lists with each list having the xs > column but a different ?t column (wt, gt, st, mt, qt, ... etc) > > If you are going to many more columns, then an array might be faster, and if speed is the ultimat

Re: How to use an array to solve the following...

2012-02-19 Thread dunbarx
Kay's is much faster than mine. Well done. Craig Newman -Original Message- From: Glen Bojsza To: How to use LiveCode Sent: Sun, Feb 19, 2012 9:49 pm Subject: Re: How to use an array to solve the following... Hi Kay, This looks very good mainly the use of case with the dec

Re: How to use an array to solve the following...

2012-02-19 Thread dunbarx
I am an old HyperCarder, so I tend to attack things in an old fashioned way. I use arrays, but think that the decisions needed here may not use them to any great advantage. I am usually wrong. I tried this with a worst case list of 20,000 lines, that is, no adjacent lines in your sense, to ma

Re: How to use an array to solve the following...

2012-02-19 Thread Glen Bojsza
Hi Kay, This looks very good mainly the use of case with the decision being the switch... never thought about that. Also, I didn't realize that arrays would be slower... I will test this with some of the data sets ... currently up to 80,000 lines but with values I have indicated... but I like the

Re: How to use an array to solve the following...

2012-02-19 Thread Kay C Lan
Here's the same solution, but with 101 records. On my machine, over 3 runs I get, 4924 millisec, 4932 ms, 4914 ms. I'm sure others will now improve on that. There are a couple of extra lines to do the timing which you'd remove for your solution. on mouseUp --create the dummy list put 1

Re: How to use an array to solve the following...

2012-02-19 Thread Kay C Lan
Whoops typo, the start dummy list is 10 6 80 7 130 23 140 2 160 22 <--- 160, not 150 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://list

Re: How to use an array to solve the following...

2012-02-19 Thread Kay C Lan
On Mon, Feb 20, 2012 at 2:53 AM, Glen Bojsza wrote: > > Is the use of arrays to solve this appropriate? Efficient? Fast? > > From another recent thread, using arrays is slower than repeat for each line, and if the values you give are realistic (not lines with 1 chars) then even if you have a

Re: How to use an array to solve the following...

2012-02-19 Thread Michael Kann
Glenn wrote: The bigger picture will be trying to do this where there may be 3 or more columns. Glenn, Please give us the "biggest" picture. Mike --- On Sun, 2/19/12, Glen Bojsza wrote: From: Glen Bojsza Subject: Re: How to use an array to solve the following... To: &

Re: How to use an array to solve the following...

2012-02-19 Thread Glen Bojsza
s is something I need to know to > even start thinking about a method. > > > Craig Newman > > > > -Original Message- > From: Glen Bojsza > To: How to use LiveCode > Sent: Sun, Feb 19, 2012 1:56 pm > Subject: How to use an array to solve the following... > &

Re: How to use an array to solve the following...

2012-02-19 Thread dunbarx
ortion? This is something I need to know to even start thinking about a method. Craig Newman -Original Message- From: Glen Bojsza To: How to use LiveCode Sent: Sun, Feb 19, 2012 1:56 pm Subject: How to use an array to solve the following... Having limited experience with arrays I

How to use an array to solve the following...

2012-02-19 Thread Glen Bojsza
Having limited experience with arrays I thought this might be a good question to ask the group. Is the use of arrays to solve this appropriate? Efficient? Fast? If the answers are yes then it will help with the bigger problem that I am trying to address but for now I am looking for advice or help