1. Another quick sequence feature request!

Hey Rob, could you implement the following:

x[*][1]

would be:

{x[1][1],x[2][1],x[3][1], etc etc etc}

I don't know what that would do to the e2c translator abilities, but it
would be nice if its possible...

William Heimbigner
icxcnika at hotpop.com
Get SySlaunch: http://www.geocities.com/icxcnika123/projects.html
Visit the UBoard - Forceful Signups Removed! -
http://uboard.proboards32.com - Threaded discussion, improved searching,
human moderating, graphical smileys, better formatting abilities (now what
else was there...)
Visit my website: http://www.geocities.com/icxcnika123

new topic     » topic index » view message » categorize

2. Re: Another quick sequence feature request!

Will,

I think that would be a fantastic idea... and while slow in
implementation, not much slower than going the other way..

Euphoria stores sequences internally as pointers. The memory location
of a 1-d sequence contains a pointer to each element. The memory
location of a 2-d sequence contains a pointer to each sub-sequence,
each of which contains pointers to elements.

To "look at" each element of a sequence, the interpreter needs to make
1 memory look-up for each element.
In a 2-d sequence:

If we wanted to look at a "horizontal slice", we'd do 1 memory look-up
to find the sub-sequence element containing that slice. Then we'd do 1
memory look-up for each element in the slice.
Total look-ups: 1 + element_number

If we wanted to look at a "vertical slice", there's no single
sub-sequence containg that slice, each element of the slice sits in a
different sub-sequence. So, to get each element, we need to do 2
look-ups. 1 to find the sub-sequence, 1 to find the element.
Total look-ups: 2 * element_number


Depending on the size of your 2d sequence, and the rate at which data
in the sequence needs to change, you could have 2 copies of the
sequence in memory... a vertical and a horizontal copy. Every change
has to be made to both sequences.

In a few other languages, two indexes can refer to the same data...
however it's something that you *REALLY* don't want to make a mistake
with.





On Thu, 23 Sep 2004 19:42:08 -0500, William Heimbigner
<icxcnika at hotpop.com> wrote:
> 
> Hey Rob, could you implement the following:
> 
> x[*][1]
> 
> would be:
> 
> {x[1][1],x[2][1],x[3][1], etc etc etc}
> 
> I don't know what that would do to the e2c translator abilities, but it
> would be nice if its possible...
> 
> William Heimbigner
> icxcnika at hotpop.com
> Get SySlaunch: http://www.geocities.com/icxcnika123/projects.html
> Visit the UBoard - Forceful Signups Removed! -
> http://uboard.proboards32.com - Threaded discussion, improved searching,
> human moderating, graphical smileys, better formatting abilities (now what
> else was there...)
> Visit my website: http://www.geocities.com/icxcnika123
> 
> 
> 
> 



-- 
MrTrick

new topic     » goto parent     » topic index » view message » categorize

3. Re: Another quick sequence feature request!

On Thu, 23 Sep 2004 19:42:08 -0500, William Heimbigner
<icxcnika at hotpop.com> wrote:

>Hey Rob, could you implement the following:
>
>x[*][1]
>
>would be:
>
>{x[1][1],x[2][1],x[3][1], etc etc etc}
>
>I don't know what that would do to the e2c translator abilities, but it
>would be nice if its possible...

why not just use:

function of_all(sequence s, integer element)
sequence t
	t=repeat(0,length(s))
	for i=1 to length(s) do
		t[i]=s[i][element]
	end for
	return t
end function

constant x={{1,2},{3,4}}
?of_all(x,1)	-- prints {1,3}
?of_all(x,2)	-- prints {2,4}

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

4. Re: Another quick sequence feature request!

On 23 Sep 2004, at 19:42, William Heimbigner wrote:

> 
> 
> Hey Rob, could you implement the following:
> 
> x[*][1]
> 
> would be:
> 
> {x[1][1],x[2][1],x[3][1], etc etc etc}
> 
> I don't know what that would do to the e2c translator abilities, but it
> would be nice if its possible...

William, it will be a cold day somewhere before RDS makes that happen. 
But you can do it with Jiri's associated lists easily enough. To do it with the 
native Eu vars, you would need access to the var list, and Rob said that 
won't happen, sorry.

Kat

new topic     » goto parent     » topic index » view message » categorize

5. Re: Another quick sequence feature request!

Kat wrote:
> 
> On 23 Sep 2004, at 19:42, William Heimbigner wrote:
> 
> > 
> > Hey Rob, could you implement the following:
> > 
> > x[*][1]
> > 
> > would be:
> > 
> > {x[1][1],x[2][1],x[3][1], etc etc etc}
> > 
> > I don't know what that would do to the e2c translator abilities, but it
> > would be nice if its possible...
> 
> William, it will be a cold day somewhere before RDS makes that happen. 
> But you can do it with Jiri's associated lists easily enough. To do it with
> the
> native Eu vars, you would need access to the var list, and Rob said that 
> won't happen, sorry.

Isn't this the old vertical slice request yet again? That is, the ability
to specify all the elements in a column of a 2-d table. You do not need
access to Euphoria's internals for that nor does one need associated lists.

  function getColumn(sequence x, integer colnum, object defval)
   sequence column
   -- One entry for each row.
   column = repeat(0, length(x))
   -- Grab each value in the specified column
   for i = 1 to length(x) do
    if atom(x[i]) or length(x[i]) < colnum then
     column[i] = defval
    else
     column[i] = x[i][colnum]
    end if
   end for
   return column
  end function

 puts(1, getColumn( {"def", " ab", "rst", "xyz", "!"}, 2, '?'))

should show "easy?" -- {'e','a','s','y','?'}


However, I agree that RDS won't we making this addition.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu