1. listed subscripting

variable={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
puts(1,variable[8,12,16,20])
--is the same as
puts(1,{variable[8],variable[12],variable[16],variable[20]})

just an idea, real easy to implement I think
even allow

? variable[8,12,16,20..26] or more complex subscriptings
--same as
? {variable[8],variable[12],variable[16],variable[20..26]}

use if for swizzled assigns as well, man I would really love this

variable[1,5,9,13]={1,2,3,4}
--same as
variable[1]=1
variable[5]=2
variable[9]=3
variable[13]=4

much cleaner code, I like it

new topic     » topic index » view message » categorize

2. Re: listed subscripting

codepilot Gmail Account wrote:
> 
> variable={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
> puts(1,variable[8,12,16,20])
> --is the same as
> puts(1,{variable[8],variable[12],variable[16],variable[20]})
> 
> just an idea, real easy to implement I think
> even allow
> 
> ? variable[8,12,16,20..26] or more complex subscriptings
> --same as
> ? {variable[8],variable[12],variable[16],variable[20..26]}
> 
> use if for swizzled assigns as well, man I would really love this
> 
> variable[1,5,9,13]={1,2,3,4}
> --same as
> variable[1]=1
> variable[5]=2
> variable[9]=3
> variable[13]=4
> 
> much cleaner code, I like it
> 
> 

Hi there,

I've had my share of problems like this too, where you could use
some sort of functionality to deal with sequences easier.
Another that comes immediately to mind is
  {a,b,c,d}=s[1,2,3,4]
which would be the same as
  a=s[1]
  b=s[2]
  c=s[3]
  d=s[4]

The reason for this is because sometimes you need to go back and
forth between using a sequence and using 'named' variables.

As (i think) you already said:
  s[1,2,3,4]={a,b,c,d}
would be nice too, to go the other way.

And as you said with the printf statement, that would be nice where
any set of values is expected (i guess you meant that too).

Gee ya know, with ideas like these this "Euphoria" may turn out to
be a real language someday :)



Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

 From "Black Knight":
"I can live with losing the good fight,
 but i can not live without fighting it".
"Well on second thought, maybe not."

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

3. Re: listed subscripting

Al Getz wrote:
> 
> codepilot Gmail Account wrote:
> > 
> > variable={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
> > puts(1,variable[8,12,16,20])
> > --is the same as
> > puts(1,{variable[8],variable[12],variable[16],variable[20]})
> > 
> > just an idea, real easy to implement I think
> > even allow
> > 
> > ? variable[8,12,16,20..26] or more complex subscriptings
> > --same as
> > ? {variable[8],variable[12],variable[16],variable[20..26]}
> > 
> > use if for swizzled assigns as well, man I would really love this
> > 
> > variable[1,5,9,13]={1,2,3,4}
> > --same as
> > variable[1]=1
> > variable[5]=2
> > variable[9]=3
> > variable[13]=4
> > 
> > much cleaner code, I like it
> > 
> > 
> Hi there,
> 
> I've had my share of problems like this too, where you could use
> some sort of functionality to deal with sequences easier.
> Another that comes immediately to mind is
>   {a,b,c,d}=s[1,2,3,4]
> which would be the same as
>   a=s[1]
>   b=s[2]
>   c=s[3]
>   d=s[4]
> 
> The reason for this is because sometimes you need to go back and
> forth between using a sequence and using 'named' variables.
> 
> As (i think) you already said:
>   s[1,2,3,4]={a,b,c,d}
> would be nice too, to go the other way.
> 
> And as you said with the printf statement, that would be nice where
> any set of values is expected (i guess you meant that too).
> 
> Gee ya know, with ideas like these this "Euphoria" may turn out to
> be a real language someday :)
> 
> 
> Al
> 


Hi All there,


a similar suggestion to Rob Craig's attention since March, 12 2005
was related to the sequence manipulation, not so much important 
but that seemed to be nice in speeding some cases, refers to the 
Slicing of sequences. Perhaps to remind it can enforce the request.
 
An expression like:
newString­ =
originalString[1..2]&"INSERT"&originalString[5..9]&originalString[27..$]

could simply become:
newString­ = originalString[1..2]&"INSERT"&[5..9]&[27..$]

It should be plain to implement, I mean more useful than complicated...

antonio

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

4. Re: listed subscripting

Antonio Alessi wrote:
> An expression like:
> }}}
<eucode>
> newString­ =
> originalString[1..2]&"INSERT"&originalString[5..9]&originalString[27..$]
> </eucode>
{{{

> could simply become:
> }}}
<eucode>
> newString­ = originalString[1..2]&"INSERT"&[5..9]&[27..$]
> </eucode>
{{{

> It should be plain to implement, I mean more useful than complicated...

I don't think that would work very well.  What if you wanted to use multiple
strings like:

newString = originalString[1..2] & "INSERT" & otherString[3..5] & [5..9]

What would the "[5..9]" refer to?

I like the idea of listed subscripts though.  It would only be useful IMHO if it
worked with predefined sequences like:

constant REPORT_FIELDS = {1,5,9,13}

sequence item

--in some for loop
    item = record[REPORT_FIELDS]


That changes the semantics codepilot originally brought up though, ie:

variable[1,5,9,13]

does not look the same as

variable[{1,5,8,13}]

and Al Getz wrote:
> I've had my share of problems like this too, where you could use
> some sort of functionality to deal with sequences easier.
> Another that comes immediately to mind is
>   {a,b,c,d}=s[1,2,3,4]

I think Rob has already made his views clear on multiple lvalue assignment and I
tend to think it would be a headache in the context of Euphoria.

What happens (even in the case of a subscript list) if the sequence s is not as
long as the subscript list?

Gary

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

5. Re: listed subscripting

ags wrote:
> 
> Antonio Alessi wrote:
> > An expression like:
> > }}}
<eucode>
> > newString­ =
> > originalString[1..2]&"INSERT"&originalString[5..9]&originalString[27..$]
> > </eucode>
{{{

> > could simply become:
> > }}}
<eucode>
> > newString­ = originalString[1..2]&"INSERT"&[5..9]&[27..$]
> > </eucode>
{{{

> > It should be plain to implement, I mean more useful than complicated...
> 
> I don't think that would work very well.  What if you wanted to use multiple
> strings like:
> 
> }}}
<eucode>
> newString = originalString[1..2] & "INSERT" & otherString[3..5] & [5..9]
> </eucode>
{{{

> What would the "[5..9]" refer to?

Hi Gary,

The last declared sequence, of course. I don't see where the problem arises.
If I had put to you the same question, which could have been you answer?

antonio

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

Search



Quick Links

User menu

Not signed in.

Misc Menu