Well I guess my first way of explaining it was a complete bust. :)

It's not going to be worth me discussing your reply to my first attempt.

List context means that something appears in the context of a list.

For example, given the list of characters EEEEAEEEE, A appears
in the context of a list of 9 characters.

Flattening a list means creating a new list from an old list such
that any scalar items in the old list are just copied into the new
list and any inner list items in the old list are copied one element
at a time into the new list.

In code:

>  1 ,2, [3,4], 5, 6
( 1 2 [3 4] 5 6)

shows that the resulting list is 5 elements, with the third being
the single list [3,4] because it does *not* flatten in list context.

In contrast, in:

>  1 ,2, |[3,4], 5, 6
( 1 2 3 4 5 6)

we get 6 elements instead because the `|` makes its right hand
side argument flatten into the list context in which it appears.

I won't be surprised to hear that's left you more confused, not less.

If so it'll be time for someone else to try and explain it. :)

--
raiph


On Fri, Oct 5, 2018 at 10:14 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 10/5/18 2:10 PM, ToddAndMargo via perl6-users wrote:
> > On 10/2/18 5:31 PM, Tony Ewell wrote:
> >> Hi All,
> >>
> >> I have been using "flatten" for a while.  I kinda-sotra know
> >> what it means.
> >>
> >>  From the following,
> >>
> >> https://docs.perl6.org/routine/[%20]#language_documentation_Operators
> <https://docs.perl6.org/routine/%5B%20%5D#language_documentation_Operators>
> >>
> >>        The Array constructor returns an itemized Array that does not
> >>        flatten in list context.
> >>
> >> What exactly do they mean by "flatten" and "list context"?
> >>
> >> Many thanks,
> >> -T
> >
> > Whoever just wrote me on "flatten", would they please
> > resend.  My iMap server is on the fritz again.
>
>
> It just showed up:
>
> > EEEEAEEEE
> >     A
> >     A
> >
> > Hopefully you see emails in a fixed width font and the As are in a
> vertical line.
> > If not, imagine they were, so there's a T shape.
> >
> > Imagine the horizontal line of four Es, then 3 As vertically, then four
> more Es, is a list.
> >
> > In this scenario, the horizontal line is a list of 9 elements.
> >
> > The vertical line is an array (which is an "itemized" list) that
> > has not flattened into the outer list .
> >
> > If it had flattened, you'd have instead ended up with 11 elements:
> >
> > EEEEAAAEEEE
> >
> > Make sense?
> >
> > --
> > raiph
> >
>
> Thanks raiph!
>
> so
>
> xxxyyyzzz
>    a
>       b
>
> would show up how?  Or do the letter need
> to be the same?
>

Reply via email to