GithubHelp home page GithubHelp logo

Comments (6)

lizmat avatar lizmat commented on August 11, 2024 2

That is what commit rakudo/rakudo@d0ec99a861 fixed: rakudo HEAD now says:

$ raku -e 'say --«<a b c d c d>.BagHash'
BagHash(c d)

as expected.

from problem-solving.

lizmat avatar lizmat commented on August 11, 2024

Related: rakudo/rakudo@d0ec99a861

from problem-solving.

frithnanth avatar frithnanth commented on August 11, 2024

OK, I understand that it's about the difference between post and pre-decrement.
Obviously (now :-) ) post-decrement returns the original value, then decrements the content of the variable. The pre-decrement does it in the opposite order.
So

$ raku -e 'say [1,2,3,4,5]»--'
[1 2 3 4 5]

while

raku -e 'say --«[1,2,3,4,5]'
[0 1 2 3 4]

Yet doing the same on a BagHash still returns strange results using the stock Rakudo v2022.07:

$ raku -e 'say --«<a b c d c d>.BagHash' 
BagHash(d)
$ raku -e 'say --«<a b c d c d>.BagHash'
BagHash(c)
$ raku -e 'say --«<a b c d c d>.BagHash'
BagHash(c d)

(Those are really three successive tests on my computer :-o )

from problem-solving.

2colours avatar 2colours commented on August 11, 2024

Quoting from https://docs.raku.org/language/operators#index-entry-hyper_%3C%3C-hyper_%3E%3E-hyper_%C2%AB-hyper_%C2%BB-Hyper_operators:

Hyper operators can work with hashes. The pointy direction indicates if missing keys are to be ignored in the resulting hash. The enclosed operator operates on all values that have keys in both hashes.

I think it makes sense that >>. behaves similarly, operating on the values of the Associative data types. I'm not sure if the issue was concerned with this approach but maybe it's good to point out that this seems to derived from related documented behavior.

There are still problems with the semantics/documentation of hyper operators, I wanted to open an issue for that, getting into it now.

EDIT: #346 is ready now.

from problem-solving.

raiph avatar raiph commented on August 11, 2024

@2colours

Quoting from [doc]:

The pointy direction indicates if missing keys are to be ignored in the resulting hash. The enclosed operator operates on all values that have keys in both hashes.

Aiui that doc is about binary op hypers ("both hashes", i.e. "missing keys" is about one hash having a key and the other not and so the direction controls whether the mismatch means that element is dropped or not), not unary ops like this issue. I'm not seeing a connection.

from problem-solving.

2colours avatar 2colours commented on August 11, 2024

@raiph

I am making the connection by saying:

I think it makes sense that >>. behaves similarly, operating on the values of the Associative data types.

Since it seemed the "operating on the values" part may not be written down for the >>. call.

from problem-solving.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.