Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list repeated once not truncating #3274

Closed
p6rt opened this issue Dec 24, 2013 · 5 comments
Closed

list repeated once not truncating #3274

p6rt opened this issue Dec 24, 2013 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Dec 24, 2013

Migrated from rt.perl.org#120861 (status was 'rejected')

Searchable as RT120861$

@p6rt
Copy link
Author

p6rt commented Dec 24, 2013

From @finanalyst

r​: my @​s=(0,1,0.5,0.4)[^3]; my @​t=((0,1,0.5,0.4) xx 1)[^3]; say @​s == @​t
<camelia> rakudo-parrot d72797, rakudo-jvm d72797​: OUTPUT«False␤»

Output should be True

((0,1,0.5,0.4) xx 1)
produces a four element list, and so does
((0,1,0.5,0.4) xx 1)[^3]

but the latter should be a three element list.

I think

Richard (finanalyst)

@p6rt
Copy link
Author

p6rt commented Dec 25, 2013

From @timo

My thoughts on this are as follows​:

  < timotimo> r​: .say for ((1, 2, 3) xx 2)
  <+camelia> rakudo-parrot 6d54dc, rakudo-jvm 6d54dc​: OUTPUT«1␤2␤3␤1␤2␤3␤»

since a for loop will evaluate the result of the xx operation in list context and flatten it, and the output of a .perl on it is​:

  < timotimo> r​: ((1, 2, 3) xx 2).perl.say
  <+camelia> rakudo-parrot 6d54dc, rakudo-jvm 6d54dc​: OUTPUT«((1, 2, 3), (1, 2, 3)).list␤»

the postcircumfix should flatten, too.

If you write $(1, 2, 3) xx 2 instead, it should naturally not flatten, just as the for loop wouldn't.

@p6rt
Copy link
Author

p6rt commented Dec 25, 2013

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

From @moritz

Hi,

On Tue Dec 24 03​:15​:50 2013, rnhainsworth@​gmail.com wrote​:

r​: my @​s=(0,1,0.5,0.4)[^3]; my @​t=((0,1,0.5,0.4) xx 1)[^3]; say @​s == @​t
<camelia> rakudo-parrot d72797, rakudo-jvm d72797​: OUTPUT«False␤»

By the current rules (changed during the Great List Refactoring), this is now correct, since @​list xx 1 produces a one-element list, and subscripting with [^3] doesn't flatten anymore.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

@moritz - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant