1. [poll] all element reference

Hello,

I'd like to test an idea that could be useful in some cases.

Would it be a great amount of work to introduce * in the
sequence referencing? I would also appreciate "high level"
comments whether it breaks the logic of the language in 
any ways...

constant x={
	{"John",1},
	{"Mary",5},
	{"Andy",2},
	{"Suse",7},
	{"Jack",5}}

-- following line would print {1,5,2,7,5}
? x[*][2]


For me the major advantage would be in cases like this:

-- following line would return 4
? find(7,x[*][2])

-- currently the search should be handled like this
for i=1 to length(x) by 1 do
	if x[i][2]=7 then
		? i
		exit
	end if
end for


What do you think?

Yours,

Salix

new topic     » topic index » view message » categorize

2. Re: [poll] all element reference

Salix wrote:
> 
> Hello,
> 
> I'd like to test an idea that could be useful in some cases.
> 
> Would it be a great amount of work to introduce * in the
> sequence referencing? I would also appreciate "high level"
> comments whether it breaks the logic of the language in 
> any ways...
> 
> }}}
<eucode>
> constant x={
> 	{"John",1},
> 	{"Mary",5},
> 	{"Andy",2},
> 	{"Suse",7},
> 	{"Jack",5}}
> 
> -- following line would print {1,5,2,7,5}
> ? x[*][2]
> </eucode>
{{{

> 
> For me the major advantage would be in cases like this:
> 
> }}}
<eucode>
> -- following line would return 4
> ? find(7,x[*][2])
> 
> -- currently the search should be handled like this
> for i=1 to length(x) by 1 do
> 	if x[i][2]=7 then
> 		? i
> 		exit
> 	end if
> end for
> </eucode>
{{{

> 
> What do you think?
> 
> Yours,
> 
> Salix

This is a hard one to vote on. I agree with it in principle, but "column access"
has been discussed here before and hasn't really gone very far. I think the main
reason is that it would be very difficult to implement.

--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.

"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare

j.

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

3. Re: [poll] all element reference

Salix wrote:

> I'd like to test an idea that could be useful in some cases.
> 
> Would it be a great amount of work to introduce * in the
> sequence referencing? I would also appreciate "high level"
> comments whether it breaks the logic of the language in 
> any ways...
> 
> }}}
<eucode>
> constant x={
> 	{"John",1},
> 	{"Mary",5},
> 	{"Andy",2},
> 	{"Suse",7},
> 	{"Jack",5}}
> 
> -- following line would print {1,5,2,7,5}
> ? x[*][2]
> </eucode>
{{{

> 
> For me the major advantage would be in cases like this:
> 
> }}}
<eucode>
> -- following line would return 4
> ? find(7,x[*][2])
> 
> -- currently the search should be handled like this
> for i=1 to length(x) by 1 do
> 	if x[i][2]=7 then
> 		? i
> 		exit
> 	end if
> end for
> </eucode>
{{{

> 
> What do you think?

<http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=9&fromYear=9&toMonth=9&toYear=9&postedBy=Derek+Parnell&keywords=getColumn>

HTH,
   Juergen

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

4. Re: [poll] all element reference

Jason Gade wrote:
> 
> 
> [...] "column access" has been discussed here before 
> and hasn't really gone very far. I think the main reason 
> is that it would be very difficult to implement.

You are right. The "column access" seems to have some history: 
http://www.openeuphoria.org/cgi-bin/esearch.exu?thread=1&fromMonth=8&fromYear=9&toMonth=A&toYear=9&keywords=%22Another+quick+sequence+feature+request!%22
Thanks for pointing out! :-]

Rgds,

Salix

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

5. Re: [poll] all element reference

Juergen Luethje wrote:
>  
> <<a
> href="http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=9&fromYear=9&toMonth=9&toYear=9&postedBy=Derek+Parnell&keywords=getColumn">http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=9&fromYear=9&toMonth=9&toYear=9&postedBy=Derek+Parnell&keywords=getColumn</a>>
> 

If you suggest me to write a function for it then I should 
agree that it's not a demanding work. On the other hand 
[*] seems to be more flexibe and handy. Just try to compare 
the number of characters hit for the example below. smile

But I think the Patrick Barnes email in the same discussion 
should make me thinking. My justification for this feature 
was a custom find() situation that I meet regularly. But due 
to the memory requirement [*] might not be efficient at all. sad

-- some more example
constant x={
	{"John",1,74},
	{"Mary",5},
	{"Andy",2,68},
	{"Suse",7,62},
	{"Jack",5,84}}

-- following line would print {1,5,2,7,5}
? x[*][2]

-- following line would print "oanua"
? x[*][1][2]

-- following line would print {'J',1,74}
? x[1][*][1]


Cheers,

Salix

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

6. Re: [poll] all element reference

Salix wrote:
> 
> Hello,
> 
> I'd like to test an idea that could be useful in some cases.
> 
> Would it be a great amount of work to introduce * in the
> sequence referencing? I would also appreciate "high level"
> comments whether it breaks the logic of the language in 
> any ways...
> 
> }}}
<eucode>
> constant x={
> 	{"John",1},
> 	{"Mary",5},
> 	{"Andy",2},
> 	{"Suse",7},
> 	{"Jack",5}}
> 
> -- following line would print {1,5,2,7,5}
> ? x[*][2]
> </eucode>
{{{

> 
> For me the major advantage would be in cases like this:
> 
> }}}
<eucode>
> -- following line would return 4
> ? find(7,x[*][2])
> 
> -- currently the search should be handled like this
> for i=1 to length(x) by 1 do
> 	if x[i][2]=7 then
> 		? i
> 		exit
> 	end if
> end for
> </eucode>
{{{

> 
> What do you think?
> 
> Yours,
> 
> Salix

A long, inconclusive thread was dealing with [] with exactly the same meaning.
This sort of construct is sorely needed. Try searching for [] in 2003-2004 when
poster is either CChris or Pete Lomax.

CChris

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

7. Re: [poll] all element reference

Salix wrote:
> 
> Juergen Luethje wrote:
> >  
> > <<a
> > href="http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=9&fromYear=9&toMonth=9&toYear=9&postedBy=Derek+Parnell&keywords=getColumn">http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=9&fromYear=9&toMonth=9&toYear=9&postedBy=Derek+Parnell&keywords=getColumn</a>>
> > 
> 
> If you suggest me to write a function for it then I should 
> agree that it's not a demanding work. On the other hand 
> [*] seems to be more flexibe and handy. Just try to compare 
> the number of characters hit for the example below. smile
> 
> But I think the Patrick Barnes email in the same discussion 
> should make me thinking. My justification for this feature 
> was a custom find() situation that I meet regularly. But due 
> to the memory requirement [*] might not be efficient at all. sad
> 
> }}}
<eucode>
> -- some more example
> constant x={
> 	{"John",1,74},
> 	{"Mary",5},
> 	{"Andy",2,68},
> 	{"Suse",7,62},
> 	{"Jack",5,84}}
> 
> -- following line would print {1,5,2,7,5}
> ? x[*][2]
> 
> -- following line would print "oanua"
> ? x[*][1][2]
> 
> -- following line would print {'J',1,74}
> ? x[1][*][1]
> </eucode>
{{{

> 
> Cheers,
> 
> Salix

That's the main issue. For it to work right, we'd need to have a "table" native
type to denote a set of columns, each of which with its type. It would be
organised in memory so that [] or [*] could be done more efficiently than by
writing the getColumn() function.

btw, thee way out I use more or less often is to organise tables by field, not
by record. This means having one sequence per field, and recors are of the form
{field_1[i];field_2[i],...}. According to whether you need to access the table
one record or one field at a time, this may be a more efficient alternate
strategy.

CChris

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

8. Re: [poll] all element reference

CChris wrote:

<snip>

> btw, thee way out I use more or less often is to organise tables by field, not
> by record. This means having one sequence per field, and recors are of the
> form
> {field_1[i];field_2[i],...}. According to whether you need to access the table
> one record or one field at a time, this may be a more efficient alternate
> strategy.
> 
> CChris

See also Jiri Babor's contributions according tables:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=jiri+tables

HTH,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu