Re: Why equal(x[n], x[n..n])=0 ?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Fernando Bauer wrote:
> 
> Derek Parnell wrote:
> > 
> > Fernando Bauer wrote:
> > 
> > > > Another way to look at is this ...
> > > > 
> > > >   s[3 .. 4] is "er"
> > > >   s[3 .. 3] is "e"
> > > Ok. But why s[3..3] is not 'e'? Why the original 'e' is transformed in "e"
> > > ?
> > 
> > It seems that you are not thinking things through clearly. The character 'e'
> > has not been transformed. 
> Let me see the dictionary:
> transform = "To change markedly the form or appearance of"
> change = "To cause to be different".
> Now, we have originally an atom 'e' (form A). After slicing we have a sequence
> "e" (form B). Clearly, form A != form B (even in computer memory), so slicing
> changes the form A to form B, and this is the definition of "transform" above.
> So I conclude that that slice transforms 'e' into "e".

I'm starting to feel sorry for you.

I have an apple. I put the apple into a bucket. Is the apple transformed? I
don't think so. It's still the same apple. No change (markedly or otherwise) in
either form or appearance.

I have an atom. I put the atom into a sequence. Is the atom transformed? I don't
think so.

> 
> > 
> > The bucket analogy is an excellent one. 
> > 
> > If you have a bucket of fruit, and you want to create a NEW bucket of fruit
> > using one piece of fruit from the initial one, the syntax to do that is 
> > 
> >     newBucket = oldBucket[n..n]
> > 
> > If you have a bucket of fruit, and you want to look at one piece of fruit
> > that
> > is in it, the syntax to do that is 
> > 
> >     theFruit = oldBucket[n]
> > 
> > As you can see, the syntax you actually use depends on what you want to
> > achieve.
> > The slice syntax [x..y] gives you a new sequence/container/bucket, and the
> > element
> > reference syntax [z] gives you one element from a container.
> > 
> > > Yes. The manual is also very clear about this. However, 
> > > the meaning of my question is another:
> > > Why does Euphoria (the manual) define slices 
> > > like x[n..n] and x[n] differently?
> > 
> > You misunderstand, it seems.
> I dont't think so. Probably my question is not precise. Let me try again:
> Why does Euphoria (the manual) define slice x[n..n] different from
> subscription
> x[n]?


Maybe it's because they are different things? 

How plainly do we all have to say the same thing over and over and over and over
and over ... again before you get it.  A slice is not a subscription! This is
really not rocket surgery, you know.

> 
> > 
> >    [n..n] IS a slice, and [n] IS NOT a slice. 
> I know this! This is the syntax definition of slice. This is clear in the
> manual!
> My question is: why doesn't the interpreter transform the slice into a
> subscript
> when the indexes are equal? 

I could say "Because that would be dumb", but that would be rude. So let's try
another (yes, yet another simple example that refuse to understand).

If we had it your way, we would have ...

  s[n .. n + 2]  is a sequence
  s[n .. n + 1]  is a sequence
  s[n .. n + 0]  is not a sequence
  s[n .. n + -1] is a sequence

Now that is just not cool. That would force us to always check for this
"special" case in our code. And that is really a bad idea, no?

You seem to be saying that whenever we reference a sequence that happens to
contain exactly one element, that the element should be the value of the
expression rather than the sequence. Honestly? That is really stupid.

I'm sorry that you can't see that. 

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu