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.squish does not always return the first list element #3762

Closed
p6rt opened this issue Mar 28, 2015 · 9 comments
Closed

List.squish does not always return the first list element #3762

p6rt opened this issue Mar 28, 2015 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Mar 28, 2015

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

Searchable as RT124205$

@p6rt
Copy link
Author

p6rt commented Mar 28, 2015

From @edwinst

According to its definition, squish should always return at least the first list element in the result list, no matter what &with returns.

Currently it can happen that squish returns an empty list if &with returns true on the first comparison​:

This is perl6 version 2015.03 built on MoarVM version 2015.03

<a a>.squish(​:with(-> $a, $b {1})).perl.say
().list

This works with unique​:

<a a>.unique(​:with(-> $a, $b {1})).perl.say
("a",).list

@p6rt
Copy link
Author

p6rt commented Aug 27, 2015

From @coke

On Sat Mar 28 16​:15​:48 2015, esteiner wrote​:

According to its definition, squish should always return at least the
first list element in the result list, no matter what &with returns.

Currently it can happen that squish returns an empty list if &with
returns true on the first comparison​:

This is perl6 version 2015.03 built on MoarVM version 2015.03

<a a>.squish(​:with(-> $a, $b {1})).perl.say
().list

This works with unique​:

<a a>.unique(​:with(-> $a, $b {1})).perl.say
("a",).list

I don't see this in the synopses, but only in the test file, and it looks like the tests were originally added after this ticket was opened. Can we get a ruling as to whether this is required? (Or a pointer to something in the Syn?)

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 27, 2015

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

@p6rt
Copy link
Author

p6rt commented Sep 15, 2015

From @usev6

On Thu Aug 27 03​:06​:07 2015, coke wrote​:

On Sat Mar 28 16​:15​:48 2015, esteiner wrote​:

According to its definition, squish should always return at least the
first list element in the result list, no matter what &with returns.

Currently it can happen that squish returns an empty list if &with
returns true on the first comparison​:

This is perl6 version 2015.03 built on MoarVM version 2015.03

<a a>.squish(​:with(-> $a, $b {1})).perl.say
().list

This works with unique​:

<a a>.unique(​:with(-> $a, $b {1})).perl.say
("a",).list

I don't see this in the synopses, but only in the test file, and it
looks like the tests were originally added after this ticket was
opened. Can we get a ruling as to whether this is required? (Or a
pointer to something in the Syn?)

I think the relevant sentence from S32/Containers.html is

  "Returns a list of values from the invocant/argument list
  where runs of more than one value are replaced with only
  the first instance."

AFAIU .squish is not meant to wipe out all values -- regardless of the
comparison function provided via :with. The bug report looks valid to me.

For the records​: :with was added to the design docs with commit ec1b7c619d
(which has a link to the IRC logs) and was removed less than 24 hours later
(c313c2918e). It was implemented for Rakudo with commit 8d851b7831.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Sep 15, 2015

From @usev6

On Thu Aug 27 03​:06​:07 2015, coke wrote​:

On Sat Mar 28 16​:15​:48 2015, esteiner wrote​:

According to its definition, squish should always return at least the
first list element in the result list, no matter what &with returns.

Currently it can happen that squish returns an empty list if &with
returns true on the first comparison​:

This is perl6 version 2015.03 built on MoarVM version 2015.03

<a a>.squish(​:with(-> $a, $b {1})).perl.say
().list

This works with unique​:

<a a>.unique(​:with(-> $a, $b {1})).perl.say
("a",).list

I don't see this in the synopses, but only in the test file, and it
looks like the tests were originally added after this ticket was
opened. Can we get a ruling as to whether this is required? (Or a
pointer to something in the Syn?)

I think the relevant sentence from S32/Containers.html is

  "Returns a list of values from the invocant/argument list
  where runs of more than one value are replaced with only
  the first instance."

AFAIU .squish is not meant to wipe out all values -- regardless of the
comparison function provided via :with. The bug report looks valid to me.

For the records​: :with was added to the design docs with commit ec1b7c619d
(which has a link to the IRC logs) and was removed less than 24 hours later
(c313c2918e). It was implemented for Rakudo with commit 8d851b7831.

@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

From @usev6

This works now (fixed with commit )​:

$ perl6-m -e '<a a>.squish(​:with(-> $a, $b {1})).perl.say'
("a",).Seq

The tests in S32-list/squish.t are passing now. I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

From @usev6

This works now (fixed with commit )​:

$ perl6-m -e '<a a>.squish(​:with(-> $a, $b {1})).perl.say'
("a",).Seq

The tests in S32-list/squish.t are passing now. I'm closing this ticket as 'resolved'.

@p6rt p6rt closed this as completed Sep 18, 2015
@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

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

@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

From @usev6

Fix commit​: 0921fa43f8

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