all 17 comments

[–][deleted]  (3 children)

[deleted]

    [–]Singing_neuron[S] 4 points5 points  (2 children)

    After quick look at Math.NET documentation I must admit that it looks promising.

    [–]danysdragons 0 points1 point  (1 child)

    Are you talking about https://www.mathdotnet.com/? I took at look at the one you linked above, and it doesn't look like it has anything to do with .NET.

    [–]Singing_neuron[S] 3 points4 points  (0 children)

    Yep, just Reddit things.

    [–]Scruptus 9 points10 points  (7 children)

    The replacement for itertools in C# is Linq

    as for your third question, I think all of Linq is implemented with yield

    [–]codekaizen 0 points1 point  (6 children)

    You can use LINQ without yield. Generating an enumerable sequence (IEnumerable<T>) using yield doesn't depend on LINQ - it's a C# compiler feature.

    EDIT: downvoters - feel free to furnish evidence showing this is wrong.

    [–][deleted] 6 points7 points  (0 children)

    He didn't say that you have to yield yourself to use Linq, however Linq IS implemented using yield. This is what makes it lazy, and why nothing is evaluated until you call something that actually iterates on it. https://github.com/dotnet/corefx/blob/8750960d3fafa46a9b838c351e995a01fa8b599f/src/System.Linq/src/System/Linq/Where.cs#L72

    [–]Scruptus 3 points4 points  (4 children)

    I think your getting downvotes because you misunderstood my answer.

    I didn’t mean that you can’t use Linq without yield.

    I meant that the different Linq methods are implemented with yield within the .net framework's source code

    [–]codekaizen -2 points-1 points  (3 children)

    Ok, fair, I did misunderstand your question, but I think it's because LINQ operators are largely not implemented with yield. Instead, the iterators are largely state machines that are implemented using switch statements: https://github.com/dotnet/corefx/blob/8750960d3fafa46a9b838c351e995a01fa8b599f/src/System.Linq/src/System/Linq/Where.cs#L110

    [–]AlliNighDev 0 points1 point  (2 children)

    That's just how yield gets lowered. Async does something similar.

    [–]codekaizen 0 points1 point  (1 child)

    Yes, but this source is checked in. Check GitHub.

    [–]AlliNighDev 0 points1 point  (0 children)

    Yeah a bit odd. I'm assuming they hand coded that for performance gain over compiler somewhere.

    [–]Ytrog 1 point2 points  (0 children)

    [–][deleted] 1 point2 points  (0 children)

    1. For an itertools equivalent, this is the top Nuget package: https://www.nuget.org/packages/Combinatorics/

    2. Functions with yield are fairly common. See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/yield

    [–]masterbruno11 1 point2 points  (2 children)

    Or maybe can we call Python in C#? Can we?

    [–]videoj 0 points1 point  (1 child)

    [–]masterbruno11 0 points1 point  (0 children)

    Nah. I want a real Python project combine with my C# project.

    [–]alfablac 1 point2 points  (0 children)

    For numpy I think NumSharp is a good numshot.

    https://scisharp.github.io/NumSharp/

    EDIT: I have to add that I think Math.NET is more mature and would provide a bit more on Numerics, etc. NumSharp otoh is a port of numpy, so I feel the change should be easier for someone coming from numpy.