1. Is subscripting a slice useful

Right now subscripting a slice is not allowed.
I think that this code should print out {97,97,97,97}.

Daniel
constant asdf={"asdf","asdf","asdf","asdf"}
? asdf[1..2][1]


new topic     » topic index » view message » categorize

2. Re: Is subscripting a slice useful

codepilot Gmail Account wrote:
> 
> Right now subscripting a slice is not allowed.
> I think that this code should print out {97,97,97,97}.

constant asdf={"asdf","asdf","asdf","asdf"}
? asdf[1..2][1]


Looks like it should print {'a','s','d','f'}

because asdf[1..2] is { "asdf", "asdf" }

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

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

3. Re: Is subscripting a slice useful

On Fri, 08 Oct 2004 14:44:29 -0700, cklester <guest at rapideuphoria.com> wrote:
> 
> posted by: cklester <cklester at yahoo.com>
> 
> codepilot Gmail Account wrote:
> >
> > Right now subscripting a slice is not allowed.
> > I think that this code should print out {97,97,97,97}.
> 
> }}}
<eucode>
> constant asdf={"asdf","asdf","asdf","asdf"}
> ? asdf[1..2][1]
> </eucode>
{{{

> 
> Looks like it should print {'a','s','d','f'}
> 
> because asdf[1..2] is { "asdf", "asdf" }
since asdf[1..2] is { "asdf", "asdf" } and asdf[1..2][1] is currently
illegal, it could get the 1st subscript from every sequence in the
slice, while asdf[1..2][2] gets the second. So that
asdf[1..2][subscript] is the same as
{asdf[1..2][1][subscript],asdf[1..2][2][subscript],asdf[1..2][3][subscript],asdf[1..2][4][subscript]}


> 
> -=ck
> "Programming in a state of EUPHORIA."
> http://www.cklester.com/euphoria/
> 
> 
> 
> 
>

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

4. Re: Is subscripting a slice useful

Another good thing would be, subscripting inline constants.
? {"asdf"}[1]
prints 'a'


On Fri, 8 Oct 2004 15:36:03 -0700, codepilot Gmail Account
<codepilot at gmail.com> wrote:
> 
> 
> On Fri, 08 Oct 2004 14:44:29 -0700, cklester <guest at rapideuphoria.com>
> wrote:
> >
> > posted by: cklester <cklester at yahoo.com>
> >
> > codepilot Gmail Account wrote:
> > >
> > > Right now subscripting a slice is not allowed.
> > > I think that this code should print out {97,97,97,97}.
> >
> > }}}
<eucode>
> > constant asdf={"asdf","asdf","asdf","asdf"}
> > ? asdf[1..2][1]
> > </eucode>
{{{

> >
> > Looks like it should print {'a','s','d','f'}
> >
> > because asdf[1..2] is { "asdf", "asdf" }
> since asdf[1..2] is { "asdf", "asdf" } and asdf[1..2][1] is currently
> illegal, it could get the 1st subscript from every sequence in the
> slice, while asdf[1..2][2] gets the second. So that
> asdf[1..2][subscript] is the same as
>
> {asdf[1..2][1][subscript],asdf[1..2][2][subscript],asdf[1..2][3][subscript],asdf[1..2][4][subscript]}
> 
> >
> > -=ck
> > "Programming in a state of EUPHORIA."
> > http://www.cklester.com/euphoria/
> >
> >
> 
> 
>

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

5. Re: Is subscripting a slice useful

On Fri, 8 Oct 2004 14:26:12 -0700, codepilot Gmail Account
<codepilot at gmail.com> wrote:

>Right now subscripting a slice is not allowed.
>
>}}}
<eucode>
>constant asdf={"asdf","asdf","asdf","asdf"}
>? asdf[1..2][1]
></eucode>
{{{

>I think that this code should print out {97,97,97,97}.

I think you just shot yourself in the foot blink)

There is *no* way that asdf[1..2] should return anything other than a
sequence of length 2, and hence a nested subscript of that could not
possibly yield a sequence of length 4. What, in contrast, would you
expect asdf[1..4][1] to print? (Surely something else!)

This whole idea (which has been extensively discussed before) is so
open to misinterpretation it should definitely NOT be "standard".
Every application needs something different.

That said, it is not difficult. If you want to extract something from
a complex sequence then I'll happily write a function for you, given a
suitable example. If you wanted {97,97} then:

constant asdf={"asdf","asdf","asdf","asdf"}

function subscript(object o, sequence what)
object this
	this=what[1]
	what=what[2..length(what)]
	if sequence(this) then
		if length(this)!=2 then ?9/0 end if
		for i=this[1] to this[2] do
			o[i]=subscript(o[i],what)
		end for
		return o[this[1]..this[2]]
	end if
	if length(what) then
		return subscript(o[this],what)
	end if
	return o[this]
end function

? subscript(asdf,{{1,2},1})


prints {97,97}

Let me know if this does not do exactly what you want.

Regards,
Pete
PS I'd be quite surprised if anyone could prove this was significantly
slower than doing it "native". The cost is entirely in the creation of
the new sequence (aka result); the subscripting/function calls pale
into insignificance. CMIIW, if you can.

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

6. Re: Is subscripting a slice useful

On Fri, 8 Oct 2004 16:01:59 -0700, codepilot Gmail Account
<codepilot at gmail.com> wrote:

>Another good thing would be, subscripting inline constants.
>? {"asdf"}[1]
>prints 'a'
Agreed, though you have obviously over-simplified it by using a
literal 1 and adding {}. "asdf"[type] makes sense, if you want to
convert 1..4 into 'a'..'f' inline, without being forced to pre-declare
a constant.

My little pet project, posetf, actually handles this quite naturally,
and to be honest I can't quite see why Rob disallows it, though I
guess we'll all know more when 2.5 Eu in Eu arrives.

Regards,
Pete
My homepage:
http://palacebuilders.pwp.blueyonder.co.uk/euphoria.html

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

7. Re: Is subscripting a slice useful

Totally correct, my foot hurts, should be {97,97}.
And I dont think I could prove that native is much faster, but would look nicer.


On Sat, 09 Oct 2004 00:17:19 +0100, Pete Lomax
<petelomax at blueyonder.co.uk> wrote:
> 
> On Fri, 8 Oct 2004 14:26:12 -0700, codepilot Gmail Account
> <codepilot at gmail.com> wrote:
> 
> >Right now subscripting a slice is not allowed.
> >
> >}}}
<eucode>
> >constant asdf={"asdf","asdf","asdf","asdf"}
> >? asdf[1..2][1]
> ></eucode>
{{{

> >I think that this code should print out {97,97,97,97}.
> 
> I think you just shot yourself in the foot blink)
> 
> There is *no* way that asdf[1..2] should return anything other than a
> sequence of length 2, and hence a nested subscript of that could not
> possibly yield a sequence of length 4. What, in contrast, would you
> expect asdf[1..4][1] to print? (Surely something else!)
> 
> This whole idea (which has been extensively discussed before) is so
> open to misinterpretation it should definitely NOT be "standard".
> Every application needs something different.
> 
> That said, it is not difficult. If you want to extract something from
> a complex sequence then I'll happily write a function for you, given a
> suitable example. If you wanted {97,97} then:
> 
> }}}
<eucode>
> constant asdf={"asdf","asdf","asdf","asdf"}
> 
> function subscript(object o, sequence what)
> object this
>        this=what[1]
>        what=what[2..length(what)]
>        if sequence(this) then
>                if length(this)!=2 then ?9/0 end if
>                for i=this[1] to this[2] do
>                        o[i]=subscript(o[i],what)
>                end for
>                return o[this[1]..this[2]]
>        end if
>        if length(what) then
>                return subscript(o[this],what)
>        end if
>        return o[this]
> end function
> 
> ? subscript(asdf,{{1,2},1})
> </eucode>
{{{

> 
> prints {97,97}
> 
> Let me know if this does not do exactly what you want.
> 
> Regards,
> Pete
> PS I'd be quite surprised if anyone could prove this was significantly
> slower than doing it "native". The cost is entirely in the creation of
> the new sequence (aka result); the subscripting/function calls pale
> into insignificance. CMIIW, if you can.
> 
> 
> 
> 
>

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

8. Re: Is subscripting a slice useful

codepilot Gmail Account wrote:
> 
> Right now subscripting a slice is not allowed.
> I think that this code should print out {97,97,97,97}.
> 
> Daniel
> }}}
<eucode>
> constant asdf={"asdf","asdf","asdf","asdf"}
> ? asdf[1..2][1]
> </eucode>
{{{


It looks what you like to do is get the first character of each element.
This is called "vertical slicing" by some. Its like visualizing the 
original sequence as ...
 {
   { 'a', 's', 'd', 'f' },
   { 'a', 's', 'd', 'f' },
   { 'a', 's', 'd', 'f' },
   { 'a', 's', 'd', 'f' }
  }

then taking just one column.

It would be nice for some applications to be able to use fast vertical
slices, but until that day comes, doing via a function isn't so bad.

Now what would save some unnecessary variables usage would be the 
ability to slice a function return value ...

   XY = getRect(myWindow)[1..2]

the current workaround is not bad, just not optimal ...

   XY = getRect(myWindow)
   XY = XY[1..2]

-- 
Derek Parnell
Melbourne, Australia

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

9. Re: Is subscripting a slice useful

>   XY = getRect(myWindow)[1..2]
I like, I like, now do that with vertical slicing too.

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

10. Re: Is subscripting a slice useful

>>Right now subscripting a slice is not allowed.
>>>
>>>}}}
<eucode>
>>>constant asdf={"asdf","asdf","asdf","asdf"}
>>>? asdf[1..2][1]
>>></eucode>
{{{

>>>I think that this code should print out {97,97,97,97}.
> 
> 
> I think you just shot yourself in the foot blink)
> 

I disagree with this statement completely. You are using a typo from the 
original message to make your point about your personal dislike of this
construct.

> There is *no* way that asdf[1..2] should return anything other than a
> sequence of length 2,

True

> and hence a nested subscript of that could not
> possibly yield a sequence of length 4. 

False, if the intermediate sequence is made of sequences itself. Of course the 
original message didn't mean that, or I misunderstood something in ir.

> What, in contrast, would you
> expect asdf[1..4][1] to print? (Surely something else!)
> 
> This whole idea (which has been extensively discussed before) is so
> open to misinterpretation it should definitely NOT be "standard".
> Every application needs something different.

Really? Most of them need vertical slicing anyway, so it is desirable for it 
to become a standard. Could you give some examples of different schemes that 
might be concurrently needed?

[snipped remainder]

Consider a sequence with at least two levels, and look at how you access it.
Each index specification (like [3]) just selects one element. Each slice 
specification (like [1..3]) selects a *range* of elements.
Vertical slicing is not ambiguous if you consider that [3] and [3..3] are 
unambiguously referring to different objects. Slices operate on matrices 
(well, tensors in dimensions >2), and slices selectt individual elements as 
probably expected.

To come back to the original example above:

-asdf[1..2][1] would print {97,97}: select element #1 in all subsequences of 
asdf[1..2].
-asdf[1..2][3..4] would print {{100,102},{100,102}}: slice [3..4] of all 
elements of asdf[1..2].
-asdf[1][1..2] would print {97,115}, as usual.

Could you elaborate an example where this extended slicing, compatible with 
the current EU syntax, could lead to two different interpretations?

YIA
CChris

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

11. Re: Is subscripting a slice useful

On 11 Oct 2004 11:56:47 +0200, Christian Cuvier
<christian.cuvier at agriculture.gouv.fr> wrote:
> 
> 
> >>Right now subscripting a slice is not allowed.
> >>>
> >>>}}}
<eucode>
> >>>constant asdf={"asdf","asdf","asdf","asdf"}
> >>>? asdf[1..2][1]
> >>></eucode>
{{{

> >>>I think that this code should print out {97,97,97,97}.
> >
> >
> > I think you just shot yourself in the foot blink)
> >
> 
> I disagree with this statement completely. You are using a typo from the
> original message to make your point about your personal dislike of this
> construct.
> 
> > There is *no* way that asdf[1..2] should return anything other than a
> > sequence of length 2,
> 
> True
> 
> > and hence a nested subscript of that could not
> > possibly yield a sequence of length 4.
> 
> False, if the intermediate sequence is made of sequences itself. Of course the
> original message didn't mean that, or I misunderstood something in ir.
> 
> > What, in contrast, would you
> > expect asdf[1..4][1] to print? (Surely something else!)
> >
> > This whole idea (which has been extensively discussed before) is so
> > open to misinterpretation it should definitely NOT be "standard".
> > Every application needs something different.
> 
> Really? Most of them need vertical slicing anyway, so it is desirable for it
> to become a standard. Could you give some examples of different schemes that
> might be concurrently needed?
> 
> [snipped remainder]
> 
> Consider a sequence with at least two levels, and look at how you access it.
> Each index specification (like [3]) just selects one element. Each slice
> specification (like [1..3]) selects a *range* of elements.
> Vertical slicing is not ambiguous if you consider that [3] and [3..3] are
> unambiguously referring to different objects. Slices operate on matrices
> (well, tensors in dimensions >2), and slices selectt individual elements as
> probably expected.
> 
> To come back to the original example above:
> 
> -asdf[1..2][1] would print {97,97}: select element #1 in all subsequences of
> asdf[1..2].
> -asdf[1..2][3..4] would print {{100,102},{100,102}}: slice [3..4] of all
> elements of asdf[1..2].
> -asdf[1][1..2] would print {97,115}, as usual.
> 
> Could you elaborate an example where this extended slicing, compatible with
> the current EU syntax, could lead to two different interpretations?
I don't think that it could have two different interpretations because
the current interpreter stops the value after slicing and looks for
more statements, so this would be an unambiguous feature.
I also think it would nest very well, like
myseq[1][1..2][3..4][5][6..7]+=1, would save tons of time in a very
big sequence.
Daniel

> 
> YIA
> CChris
> 
> 
> 
> 
>

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

12. Re: Is subscripting a slice useful

On 11 Oct 2004 11:56:47 +0200, Christian Cuvier
<Christian.CUVIER at agriculture.gouv.fr> wrote:

>You are using a typo from the original message to make your point 
Would that be the same typo mercilessly repeated no less than NINE
times in a subsequent post? blink)
>about your personal dislike of this construct.
I'm entitled to an opinion, last time I checked.
>
>> There is *no* way that asdf[1..2] should return anything other than a
>> sequence of length 2,
>
>True
>
>> and hence a nested subscript of that could not
>> possibly yield a sequence of length 4. 
>
>False, if the intermediate sequence is made of sequences itself.
I don't understand what you mean. Please give me an example.
>
>> This whole idea (which has been extensively discussed before) is so
>> open to misinterpretation it should definitely NOT be "standard".
>> Every application needs something different.
>
>Really? Most of them need vertical slicing anyway, so it is desirable for it 
>to become a standard. Could you give some examples of different schemes that 
>might be concurrently needed?
The complexities this introduces worry me, and I fear it is not
flexible enough to justify it. Suppose that
c =
{{{2,4,6,20}, {8,10,12,22}, {14,16,18,24}},
 {{3,6,9,30}, {12,15,18,33}, {21,24,27,36}},
 {{24,25,26,33}, {27,28,29,34}, {30,31,32,35}}}

How do you get {8,14,12,21}?

For that matter, and to spoil your fun, what is c[1..2][2..3][1..1]?

Can you explain to me why that should _not_ be
{{{8,10,12,22}}, {{12,15,18,33}}} ?

Also, do you believe that eg

	c[2..3][2][3..4]+=1

should be supported?
If so, what should the result be?
>
>[snipped remainder]
>
>Consider a sequence with at least two levels, and look at how you access it.
>Each index specification (like [3]) just selects one element. Each slice 
>specification (like [1..3]) selects a *range* of elements.
>Vertical slicing is not ambiguous if you consider that [3] and [3..3] are 
>unambiguously referring to different objects. Slices operate on matrices 
>(well, tensors in dimensions >2), and slices selectt individual elements as 
>probably expected.
>
>To come back to the original example above:
>
>-asdf[1..2][1] would print {97,97}: select element #1 in all subsequences of 
>asdf[1..2].
>-asdf[1..2][3..4] would print {{100,102},{100,102}}: slice [3..4] of all 
>elements of asdf[1..2].
>-asdf[1][1..2] would print {97,115}, as usual.
Yes, that's fine.
>
>Could you elaborate an example where this extended slicing, compatible with 
>the current EU syntax, could lead to two different interpretations?
Someone once posted that a[x..y][z] would just return a[x+z-1], and
there is certainly some logical reasoning to that, though of course it
would be utterly pointless to make a change which works that way.

Maybe something like:
c =
{{{1,1}, {1,1}, {1,1}}, {{1,1}, {1,1}, {1,1}}, {{1,1}, {1,1}, {1,1}}}

 c[2..3][2..3]+={2,3}

could give

{{{1,1}, {1,1}, {1,1}}, {{1,1}, {3,3}, {4,4}}, {{1,1}, {3,3}, {4,4}}}

or

{{{1,1}, {1,1}, {1,1}}, {{1,1}, {3,3}, {3,3}}, {{1,1}, {4,4}, {4,4}}}

or

{{{1,1}, {1,1}, {1,1}}, {{1,1}, {3,4}, {3,4}}, {{1,1}, {3,4}, {3,4}}}

To be honest I have no idea which would be correct.

Regards,
Pete

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

13. Re: Is subscripting a slice useful

> Date: Tue, 12 Oct 2004 02:03:10 +0100 From: Pete Lomax <petelomax at
> blueyonder.co.uk> Subject: Re: Is subscripting a slice useful On 11 Oct 2004
> 11:56:47 +0200, Christian Cuvier <Christian.CUVIER at agriculture.gouv.fr> wrote:
> 
>>>You are using a typo from the original message to make your point 
> 
> Would that be the same typo mercilessly repeated no less than NINE
> times in a subsequent post? blink)
> 
>>>about your personal dislike of this construct.
> 
> I'm entitled to an opinion, last time I checked.
> 

Of course, but using methods that rely on an error borders on the unfair. 
Well, that's not the main point abyway.

>>>
>>
>>>>> There is *no* way that asdf[1..2] should return anything other than a
>>>>> sequence of length 2,
>>
>>>
>>>True
>>>
>>
>>>>> and hence a nested subscript of that could not
>>>>> possibly yield a sequence of length 4. 
>>
>>>
>>>False, if the intermediate sequence is made of sequences itself.
> 
> I don't understand what you mean. Please give me an example.

Let's call this question Q0, see below.

>>>
>>
>>>>> This whole idea (which has been extensively discussed before) is so
>>>>> open to misinterpretation it should definitely NOT be "standard".
>>>>> Every application needs something different.
>>
>>>
>>>Really? Most of them need vertical slicing anyway, so it is desirable for it 
>>>to become a standard. Could you give some examples of different schemes that 
>>>might be concurrently needed?
> 
> The complexities this introduces worry me, and I fear it is not
> flexible enough to justify it. Suppose that
> c =
> {{{2,4,6,20}, {8,10,12,22}, {14,16,18,24}},
>  {{3,6,9,30}, {12,15,18,33}, {21,24,27,36}},
>  {{24,25,26,33}, {27,28,29,34}, {30,31,32,35}}}
> 
> How do you get {8,14,12,21}?
> 

You need the [] construct, which would mean "skip this level of sequencing". 
Then you can go to this point by using c[1..2][2..3][][][1].
Not flexible enough, you said?
Slicing just restricts the range of available indexes; you need another 
operator to reduce depth.

> For that matter, and to spoil your fun, what is c[1..2][2..3][1..1]?
> Can you explain to me why that should _not_ be
> {{{8,10,12,22}}, {{12,15,18,33}}} ?


Well, I can undestand how you got there, but it's not consistent:
c[1..2] is {{{2,4,6,20}, {8,10,12,22}, {14,16,18,24}},
             {{3,6,9,30}, {12,15,18,33}, {21,24,27,36}}}
Apply [2..3] to it -> {{{8,10,12,22}, {14,16,18,24}},
                        {{12,15,18,33}, {21,24,27,36}}}

(answers Q0 btw)
Apply [1..1] to it -> {{{8}, {14}}, {{12}, {21}}}

Explanation is: c[1..2][2..3][1..1] restricts the first index level to lie 
between 1 and 2, the second one between 2 and 3 and the third one between 1 and
1.

{{{8,10,12,22}}, {{12,15,18,33}}} would be (c[1..2][2..3])[1..2][1..1]
by considering the intermediate result above as a 2x2 matrix and operating on 
it *as such*. Forgetting the parens would be an error, since there are 3 index 
levels only, not 4.

> Also, do you believe that eg
> 
> 	c[2..3][2][3..4]+=1
> 
> should be supported?

No, but c[2..3][2..2][3..4]+=1 would. Result would be

  {{{2,4,6,20}, {8,10,12,22}, {14,16,18,24}},
   {{3,6,9,30}, {12,15,19,34}, {21,24,28,37}},
   {{24,25,26,33}, {27,28,30,35}, {30,31,33,36}}}

c[2..3][2][3..4] is {{18,33},{29,34}}. You can add 1 to this, but then how to 
plug it back in?

> If so, what should the result be?
> 
>>>
>>>[snipped remainder]
>>>
>>>Consider a sequence with at least two levels, and look at how you access it.
>>>Each index specification (like [3]) just selects one element. Each slice 
>>>specification (like [1..3]) selects a *range* of elements.
>>>Vertical slicing is not ambiguous if you consider that [3] and [3..3] are 
>>>unambiguously referring to different objects. Slices operate on matrices 
>>>(well, tensors in dimensions >2), and slices selectt individual elements as 
>>>probably expected.
>>>
>>>To come back to the original example above:
>>>
>>>-asdf[1..2][1] would print {97,97}: select element #1 in all subsequences of 
>>>asdf[1..2].
>>>-asdf[1..2][3..4] would print {{100,102},{100,102}}: slice [3..4] of all 
>>>elements of asdf[1..2].
>>>-asdf[1][1..2] would print {97,115}, as usual.
> 
> Yes, that's fine.
> 
>>>
>>>Could you elaborate an example where this extended slicing, compatible with 
>>>the current EU syntax, could lead to two different interpretations?
> 
> Someone once posted that a[x..y][z] would just return a[x+z-1], and
> there is certainly some logical reasoning to that,

I hope so, but I can't grasp it atm.

> though of course it
> would be utterly pointless to make a change which works that way.
> 
> Maybe something like:
> c =
> {{{1,1}, {1,1}, {1,1}}, {{1,1}, {1,1}, {1,1}}, {{1,1}, {1,1}, {1,1}}}
> 
>  c[2..3][2..3]+={2,3}
> 
> could give
> 
> {{{1,1}, {1,1}, {1,1}}, {{1,1}, {3,3}, {4,4}}, {{1,1}, {3,3}, {4,4}}}
> 
> or
> 
> {{{1,1}, {1,1}, {1,1}}, {{1,1}, {3,3}, {3,3}}, {{1,1}, {4,4}, {4,4}}}
> 
> or
> 
> {{{1,1}, {1,1}, {1,1}}, {{1,1}, {3,4}, {3,4}}, {{1,1}, {3,4}, {3,4}}}
> 
> To be honest I have no idea which would be correct.
> 

I'd say the second one. You get the third one by c[2..3][2..3]+={{2,3}}, and 
the first one by c[2..3][2..3]+={{2},{3}}.

> Regards,
> Pete

Regards
CChris
Fire at will...

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

14. Re: Is subscripting a slice useful

On 12 Oct 2004 12:45:59 +0200, Christian Cuvier
<Christian.CUVIER at agriculture.gouv.fr> wrote:

<snip>
>>>>>> and hence a nested subscript of that could not
>>>>>> possibly yield a sequence of length 4. 
>>>>False, if the intermediate sequence is made of sequences itself.
>> I don't understand what you mean. Please give me an example.
>Let's call this question Q0, see below.
<snip>
>(answers Q0 btw)
>Apply [1..1] to it -> {{{8}, {14}}, {{12}, {21}}}
?length({{{8}, {14}}, {{12}, {21}}})
(It has tickled me, that one, <giggle>)
>You need the [] construct, which would mean "skip this level of sequencing". 
>Then you can go to this point by using c[1..2][2..3][][][1].
Oooh, lovely syntaxblink)
>{{{8,10,12,22}}, {{12,15,18,33}}} would be (c[1..2][2..3])[1..2][1..1]
Eeek blink)
>>  c[2..3][2..3]+={2,3}
>I'd say the second one. You get the third one by c[2..3][2..3]+={{2,3}}, and 
>the first one by c[2..3][2..3]+={{2},{3}}.
<snip>
>Fire at will...
I give, you win!
This is all possible, but you should at least by now understand why
*I* don't consider it an improvement to the lovely, elegant language
we all know and love.

If the majority want this, so be it, I've had my say.

Regards,
Pete

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

15. Re: Is subscripting a slice useful

Pete Lomax wrote:

[snip]

> This is all possible, but you should at least by now understand why
> *I* don't consider it an improvement to the lovely, elegant language
> we all know and love.
> 
> If the majority want this, so be it, I've had my say.

I must agree with Pete (a rare thing I suspect). The concept of 'vertical'
slicing needs a new syntax altogether, if we need to have it at all in 
the language. 

Currently the "[n..m]" notation in an expression is saying ...

"create a new sequence, and build it from elements 'n' to 'm' inclusively"

But vertical slicing implies that we don't want to use all of each element
but just a subset of each element. So the difference in semantics 
(sub-element verses full element) needs to be reflected in the syntax.
Something like "[n..m : x..y]" maybe. This is saying - build a new 
sequence from elements 'n' to 'm', but for each element just use
sub-elements 'x' to 'y'. In other words, the syntax "[n..m]" could
be thought of as shorthand for "[n..m:1..$]" 

 A = { {1,2,3}, {4,5,6}, {7,8,9}, {10,11,12} }

 Thus A[2..3 : 2] would give {5,8}
  and A[2..3 : 2..3] would give {{5,6}, {8,9}}

-- 
Derek Parnell
Melbourne, Australia

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

Search



Quick Links

User menu

Not signed in.

Misc Menu