1. Possible idea for a new built-in in Eu 2.4
- Posted by Christian.CUVIER at agriculture.gouv.fr Feb 05, 2003
- 450 views
Hi the list! I often wind up with having to search for a key at a fixed place in a sequence of sequences. The following obviously does the job: <code> function ffind(object key,integer field,sequence target) --scans the field-th elements of target for key --returns index of first record with matching entry or 0 if none found for i=1 to length(target) do if target[i][field]=key then return i end if end for --not found in this "column" return 0 end function </code> But it may be slow if target is large enough, and I suspect that, internally, there could be a way to do something like <notional code> function ffind(object key,integer field,sequence target) --same purpose, args and returns as above return find(key,target[..][field]) end function </notional code> Would the built-in be significantly faster? And is there a chance that it appears in Eu 2.4? CChris
2. Re: Possible idea for a new built-in in Eu 2.4
- Posted by jordah at btopenworld.com Feb 05, 2003
- 426 views
----- Original Message ----- From: <Christian.CUVIER at agriculture.gouv.fr> To: "EUforum" <EUforum at topica.com> Subject: Possible idea for a new built-in in Eu 2.4 > > Hi the list! > I often wind up with having to search for a key at a fixed place in a > sequence of sequences. The following obviously does the job: > > <code> > function ffind(object key,integer field,sequence target) > --scans the field-th elements of target for key > --returns index of first record with matching entry or 0 if none found > for i=1 to length(target) do > if target[i][field]=key then return i end if > end for > --not found in this "column" > return 0 > end function > </code> What happens when key is a sequence? The above function looks to work best for atoms,. Try it this way ------------------------------------------- function ffind(object key,integer field,sequence target) ------------------------------------------- for n = 1 to length(target) by 1 do if not compare(target[n][field],key) then return n end if end for return 0 end function > > But it may be slow if target is large enough, and I suspect that, > internally, there could be a way to do something like > > <notional code> > function ffind(object key,integer field,sequence target) > --same purpose, args and returns as above > return find(key,target[..][field]) > end function > </notional code> Yes, i think if there was an internal way of doing that it would be helpful....however there is none that i know of. It all boils down to looping through the sequence, sorry Jordah > > Would the built-in be significantly faster? And is there a chance that > it appears in Eu 2.4? > > CChris > > > > TOPICA - Start your own email discussion group. FREE! > ---
3. Re: Possible idea for a new built-in in Eu 2.4
- Posted by jbrown1050 at hotpop.com Feb 05, 2003
- 429 views
Again, another idea that looks nice for OpenEu. Snidely hinting, jbrown On Wed, Feb 05, 2003 at 07:30:50PM -0000, jordah at btopenworld.com wrote: > > > ----- Original Message ----- > From: <Christian.CUVIER at agriculture.gouv.fr> > To: "EUforum" <EUforum at topica.com> > Sent: Wednesday, February 05, 2003 12:02 PM > Subject: Possible idea for a new built-in in Eu 2.4 > > > > Hi the list! > > I often wind up with having to search for a key at a fixed place in a > > sequence of sequences. The following obviously does the job: > > > > <code> > > function ffind(object key,integer field,sequence target) > > --scans the field-th elements of target for key > > --returns index of first record with matching entry or 0 if none found > > for i=1 to length(target) do > > if target[i][field]=key then return i end if > > end for > > --not found in this "column" > > return 0 > > end function > > </code> > > What happens when key is a sequence? The above function looks to work best > for atoms,. Try it this way > > ------------------------------------------- > function ffind(object key,integer field,sequence target) > ------------------------------------------- > for n = 1 to length(target) by 1 do > if not compare(target[n][field],key) then > return n > end if > end for > return 0 > end function > > > > > But it may be slow if target is large enough, and I suspect that, > > internally, there could be a way to do something like > > > > <notional code> > > function ffind(object key,integer field,sequence target) > > --same purpose, args and returns as above > > return find(key,target[..][field]) > > end function > > </notional code> > > Yes, i think if there was an internal way of doing that it would be > helpful....however there is none that i know of. It all boils down to > looping through the sequence, sorry > > Jordah > > > > Would the built-in be significantly faster? And is there a chance that > > it appears in Eu 2.4? > > > > CChris > > > > > > TOPICA - Start your own email discussion group. FREE! > > > > --- > > > > TOPICA - Start your own email discussion group. FREE! -- /"\ ASCII ribbon | \ / campain against | Linux User:190064 X HTML in e-mail and | Linux Machine:84163 /*\ news, and unneeded MIME |
4. Re: Possible idea for a new built-in in Eu 2.4
- Posted by Christian.CUVIER at agriculture.gouv.fr Feb 06, 2003
- 439 views
> ----- Original Message ----- > From: <Christian.CUVIER at agriculture.gouv.fr> > To: "EUforum" <EUforum at topica.com> > Sent: Wednesday, February 05, 2003 12:02 PM > Subject: Possible idea for a new built-in in Eu 2.4 > > > > > Hi the list! > > I often wind up with having to search for a key at a fixed place in a > > sequence of sequences. The following obviously does the job: > > > > <code> > > function ffind(object key,integer field,sequence target) > > --scans the field-th elements of target for key > > --returns index of first record with matching entry or 0 if none found > > for i=1 to length(target) do > > if target[i][field]=key then return i end if > > end for > > --not found in this "column" > > return 0 > > end function > > </code> > > What happens when key is a sequence? The above function looks to work best > for atoms,. Try it this way > > ------------------------------------------- > function ffind(object key,integer field,sequence target) > ------------------------------------------- > for n = 1 to length(target) by 1 do > if not compare(target[n][field],key) then > return n > end if > end for > return 0 > end function Yep, thanks. I didn't have to look for sequences when I devised this, but you're right.Perhaps I'd prefer "if equal(key,target[n][field]" rather. > > > > But it may be slow if target is large enough, and I suspect that, > > internally, there could be a way to do something like > > > > <notional code> > > function ffind(object key,integer field,sequence target) > > --same purpose, args and returns as above > > return find(key,target[..][field]) > > end function > > </notional code> > > Yes, i think if there was an internal way of doing that it would be > helpful....however there is none that i know of. It all boils down to > looping through the sequence, sorry > > Jordah That's the point. If hopping from target[n][field] to target[n+1][field] internally amounts to computing the latter straight away, the built-in is of no use, since it doesn't make anything real faster. > > > > Would the built-in be significantly faster? And is there a chance that > > it appears in Eu 2.4? > > > > CChris CChris
5. Re: Possible idea for a new built-in in Eu 2.4
- Posted by jordah at btopenworld.com Feb 06, 2003
- 418 views
----- Original Message ----- From: <Christian.CUVIER at agriculture.gouv.fr> To: "EUforum" <EUforum at topica.com> Subject: Re: Possible idea for a new built-in in Eu 2.4 > > > > ----- Original Message ----- > > From: <Christian.CUVIER at agriculture.gouv.fr> > > To: "EUforum" <EUforum at topica.com> > > Sent: Wednesday, February 05, 2003 12:02 PM > > Subject: Possible idea for a new built-in in Eu 2.4 > > > > > > > > Hi the list! > > > I often wind up with having to search for a key at a fixed place in a > > > sequence of sequences. The following obviously does the job: > > > > > > <code> > > > function ffind(object key,integer field,sequence target) > > > --scans the field-th elements of target for key > > > --returns index of first record with matching entry or 0 if none found > > > for i=1 to length(target) do > > > if target[i][field]=key then return i end if > > > end for > > > --not found in this "column" > > > return 0 > > > end function > > > </code> > > > > What happens when key is a sequence? The above function looks to work best > > for atoms,. Try it this way > > > > ------------------------------------------- > > function ffind(object key,integer field,sequence target) > > ------------------------------------------- > > for n = 1 to length(target) by 1 do > > if not compare(target[n][field],key) then > > return n > > end if > > end for > > return 0 > > end function > > Yep, thanks. I didn't have to look for sequences when I devised this, > but you're right.Perhaps I'd prefer "if equal(key,target[n][field]" > rather. Sorry but equal is not as fast as comapre besides....before equal was introduces IIRC this is the equal i used to use...equal simply calls compare() function equal(object a,object b) return not compare(a,b) end function function equal(object a,object b) return (compare(a,b)=0) end function I won't deviate the main purpose of the thread u started.....Yes EU 2.4 should have that ability but i don't think it would be far faster. Besides, I don't think it can make it to top 10 of Rob's Todo's. Don't get me wrong, i really find that helpful. Its just that i'm speaking from my experience and knowledge of RDS Jordah > > > > > > > But it may be slow if target is large enough, and I suspect that, > > > internally, there could be a way to do something like > > > > > > <notional code> > > > function ffind(object key,integer field,sequence target) > > > --same purpose, args and returns as above > > > return find(key,target[..][field]) > > > end function > > > </notional code> > > > > Yes, i think if there was an internal way of doing that it would be > > helpful....however there is none that i know of. It all boils down to > > looping through the sequence, sorry > > > > Jordah > > That's the point. If hopping from target[n][field] to > target[n+1][field] internally amounts to computing the latter straight > away, the built-in is of no use, since it doesn't make anything real > faster. True, i feel u > > > > > > > Would the built-in be significantly faster? And is there a chance that > > > it appears in Eu 2.4? > > > > > > CChris > > CChris > Jordah > > > TOPICA - Start your own email discussion group. FREE! >