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

Cross product with a .map in the rhs yields an empty list in Rakudo #3311

Closed
p6rt opened this issue Jan 12, 2014 · 6 comments
Closed

Cross product with a .map in the rhs yields an empty list in Rakudo #3311

p6rt opened this issue Jan 12, 2014 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jan 12, 2014

Migrated from rt.perl.org#120973 (status was 'resolved')

Searchable as RT120973$

@p6rt
Copy link
Author

p6rt commented Jan 12, 2014

From @masak

<clsn> r​: say <a b>.map({$_}) X, <c d>.map({$_})
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«␤»
<clsn> What am I missing here? Shouldn't that be the same as <a b> X, <c d>?
<masak> r​: say (<a b>.map({$_}) X <c d>.map({$_}))
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«␤»
<masak> r​: say (<a b> X <c d>)
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«a c a d b c b d␤»
<jnthn> r​: say <a b>.map({$_})
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«a b␤»
<clsn> I was going to try to use stuff like that to check for
subsetness among param names, but this cropped up.
<clsn> r​: say <a b>.perl; say <a b>.map({$_}).perl
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«("a",
"b")␤("a", "b").list␤»
* masak submits rakudobug
<masak> r​: say (<a b>.map({$_}) X <c d>)
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«a c a d b c b d␤»
<masak> interesting. so it takes two maps.
<clsn> r​: say (<a b> X <c d>.map({$_}))
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«␤»
<clsn> No, only the second one it looks like.
<masak> oh!
<masak> yes.
<masak> clsn++
<masak> r​: say (<a b> X <c d>.map({$_})).perl
<camelia> rakudo-parrot 58307f, rakudo-jvm 58307f​: OUTPUT«().list␤»

@p6rt
Copy link
Author

p6rt commented Jan 15, 2014

From mark@kli.org

The problem is that the map is lazy and the X operator doesn't make it generate values​:

my $a=(1...3); my $b=(100...110).map({$_}); say $a X $b

my $a=(1...3); my $b=(100...110).map({$_}); my $c=$b[3]; say $a X $b
1 100 1 101 1 102 1 103 2 100 2 101 2 102 2 103 3 100 3 101 3 102 3 103

Note that once $b[0..3] are generated in order to put into $c, those elements--and only those--are available to the X op.

@p6rt
Copy link
Author

p6rt commented Jan 15, 2014

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

@p6rt
Copy link
Author

p6rt commented Jan 2, 2015

From @usev6

This works now​:

$ perl6 -e 'say <a b> X <c d>.map({$_})'
a c a d b c b d

$ perl6 -e 'say <a b>.map({$_}) X <c d>'
a c a d b c b d

$ perl6 -e 'say <a b>.map({$_}) X <c d>.map({$_})'
a c a d b c b d

I added tests to S03-metaops/cross.t with commit Raku/roast@d3aa62b272

I'm closing this ticket.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jan 2, 2015

From @usev6

This works now​:

$ perl6 -e 'say <a b> X <c d>.map({$_})'
a c a d b c b d

$ perl6 -e 'say <a b>.map({$_}) X <c d>'
a c a d b c b d

$ perl6 -e 'say <a b>.map({$_}) X <c d>.map({$_})'
a c a d b c b d

I added tests to S03-metaops/cross.t with commit Raku/roast@d3aa62b272

I'm closing this ticket.

@p6rt
Copy link
Author

p6rt commented Jan 2, 2015

@usev6 - Status changed from 'open' to 'resolved'

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