GithubHelp home page GithubHelp logo

Comments (8)

rossberg avatar rossberg commented on July 30, 2024

I think the design doc calls these has? Or is that different?

from motoko-base.

matthewhammer avatar matthewhammer commented on July 30, 2024

Whatever the name, this operation needs to either be higher order, or only exist within APIs for containers whose elements have a known equal function for them.

Should the type vary depending on that situation?

from motoko-base.

rossberg avatar rossberg commented on July 30, 2024

Maybe I was confused, has is meant to test key membership. Are you guys talking about value membership? Then maybe call that hasValue?

from motoko-base.

matthewhammer avatar matthewhammer commented on July 30, 2024

I'm not sure about the name, but the common idea (across finite maps, sets and sequences) could be:

Does "this thing" exist in the collection, among "those things that I want to identify there"?

For map-like collections, that "identified thing" would be a key (regardless of its associated value in the map). For sets and sequences, it would be a value, since there are no keys and thus no other way to search or identify anything. In a map, however, the identity of values is the identity of their keys.

from motoko-base.

matthewhammer avatar matthewhammer commented on July 30, 2024

FWIW, I would call the operation that I am describing contains, and have it return a Bool. It's not exactly has or hasValue, but it does one or the other, depending.

from motoko-base.

rossberg avatar rossberg commented on July 30, 2024

@matthewhammer, I'd assume that for a map you generally want both, so they should be distinguished by coherent naming conventions.

from motoko-base.

matthewhammer avatar matthewhammer commented on July 30, 2024

Agreed, you'd want both has and hasValue.

I guess you're saying that you don't also want to alias has for maps with the additional name contains (my proposal to satisfy this issue); if not, I understand. It seems strange/gross.

Not sure how to resolve the issue as stated then.

from motoko-base.

rossberg avatar rossberg commented on July 30, 2024

Still not sure what's actually being proposed. Is it

  • ask for key (has, should already present everywhere AFAIK)
  • ask for value (hasValue, would need equality function, I suppose)
  • ask for value based on predicate (essentially, Option.isSome o find)
  • ask for entry based on predicate (essentially, Option.isSome o findEntry)
  • several of the above?

Can somebody clarify?

from motoko-base.

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.