Coder Social home page Coder Social logo

Intersect about linq-collections HOT 5 OPEN

isc30 avatar isc30 commented on May 27, 2024
Intersect

from linq-collections.

Comments (5)

isc30 avatar isc30 commented on May 27, 2024 1

yep, but in the end, having special comparer for those cases is user's responsibility.
I think the best we can do is use === as default (every other method in the library uses this comparer)
I also edited my previous answer

from linq-collections.

Tholdrim avatar Tholdrim commented on May 27, 2024 1

Since EqualityComparer is there already, I'll grab this task.

from linq-collections.

nikolalukovic avatar nikolalukovic commented on May 27, 2024

I suppose we will also need to have something like an EqualityComparer to specify in which way to compare values?

We would have an optional value which would specify in which way to do an intersection. Something like this?

export interface IQueryable<TOut>
{
    intersect(other: IQueryable<TOut>, comparer?: EqualityComparer<TOut>): IEnumerable<TOut>;
}

Maybe it would also be a good idea to create comparers for simple types(string, number, etc...) which would be automatically used(depending on the type) if no comparer is specified.

from linq-collections.

isc30 avatar isc30 commented on May 27, 2024

The only place where comparers are being used currently is for orderBy, maybe it's a good idea to introduce a StrictEqualityComparer that simply does === and start using it here as default one?

We can introduce something like this:

export type EqualityComparer<T> = (left: T, right: T) => boolean;
export const StrictEqualityComparer = <T>() => (left: T, right: T) => left === right;

from linq-collections.

nikolalukovic avatar nikolalukovic commented on May 27, 2024

It all depends how precise you want to go. I'd argue that for strings, as an example, being careful about locale is a must. And === doesn't help in that case.

from linq-collections.

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.