1. RE: Strange behavior in sequence handling

On Mon, 07 May 2001, Chris Bensler wrote:

> Hi Henri, welcome to Euphoria!
> 
> If you expand the final product of L, you get this..
> L = { { {'a','b','z'} ,1,2} ,4,5}
> 
> Here is a breakdown of each indice in your final sequence..
> L[1] = { {'a','b','z'} ,1,2}
> L[2] = 4
> L[3] = 5
> 
> L[1][1] = {'a','b','z'} -- This is the first assignment you made to L
> L[1][2] = 1
> L[1][3] = 2
> 
> L[1][1][1] = 'a'
> L[1][1][2] = 'b'
> L[1][1][3] = 'z'
> 
> I hope this helps a little..
> 
> Out of curiosity, what were you expecting L[1][1] to be?

Well, I for one, was expecting L[1][]1] to be something other
than about  1000 curly brackets! At least, that's what 
? L[1][1] prints when I try his code.

Regards,
Irv

> Sequences are about the only tricky thing in EU, and even at that, once  
>you get the hang of them, you'll wonder how it could possibly be any  
>simpler! :)

new topic     » topic index » view message » categorize

2. RE: Strange behavior in sequence handling

Hi Igor,

I was just kidding. I'm not very familiar with those languages but I know that
the only data structure in LISP is the list (hence its name LISP = LISt
Processing) and you get readily lost in the many parentheses that clog a typical
LISP program. I also mentioned PROLOG because I vaguely remember that some
dialects of PROLOG provide for the manipulation of recursively defined infinite
lists that would also display something like ((((((((((((((((((((... with the 3
dots figuring infinity.

Anyway, the gap between the approaches of declarative languages like LISP and
PROLOG and imperative languages like Euphoria makes it difficult, to me at least,
to compare the situation.

Any specialist out there?

Henri Goffin

> -----Original Message-----
> From:	Igor Kachan [SMTP:kinz at peterlink.ru]
> Sent:	Monday, May 07, 2001 16:06
> To:	EUforum
> Subject:	Re: Strange behavior in sequence handling
> 
> 
> Hi Henri,
> 
> > L[1] = L		-- Still OK
> > L[1][1] = L	-- Wow! Is this LISP or Prolog or something?
> > trace(0)
> 
> Eu outputs CauseWay crash-file with message,
> if ? L, or ? L[1], or ? L[1][1]
> 
> but ? length(L)  or ? L[2]  or ? L[3] are OK.
> 
> And what does LISP or Prolog do in this case ?
> 
> Just interesting to know, I am not
> familiar with these languages.
> 
> Regards,
> Igor Kachan
> kinz at peterlink.ru
> 
>

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

3. RE: Strange behavior in sequence handling

interesting...:) i inserted a few print statements(for each assignment 
to L after the "weird" comment) and got this:

{97,98,122}
{{97,98,122},98,122}
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
CauseWay DOS Extender v3.45 Copyright 1992-99 Michael Devore.
blah blah blah...

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

4. RE: Strange behavior in sequence handling

it gives an interesting insight into the underlying implementation of 
euphoria.

in the first assignment of L (L[1] = L), the values of L are all 
integers and assigned (apparently) by value.

in the second assignment of L (L[1][1] = L), the right side is a nested 
sequence, which euphoria assigns by a pointer to the sequence structure 
(in this case, itself). no problem with the actual assignment (no 
error), but when you try to access the contents of the first element, it 
points back to its own structure recursively in an infinite loop.

so it's a feature after all - recursive variables, to go with types that 
act like functions! euphoria has hidden powers.

cheers all

tacitus

sephiroth _ wrote:
> interesting...:) i inserted a few print statements(for each assignment 
> to L after the "weird" comment) and got this:
> 
> {97,98,122}
> {{97,98,122},98,122}
> {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
> {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
> {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
> {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
> {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
> CauseWay DOS Extender v3.45 Copyright 1992-99 Michael Devore.
> blah blah blah...
> 
>

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

5. RE: Strange behavior in sequence handling


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

Search



Quick Links

User menu

Not signed in.

Misc Menu