Skip to main content
-1 votes
1 answer
58 views

I want to keep some graph traversal algorithms as generic as possible and define a protocol for this purpose: protocol Path { var distance : Int { get} var end : Node { get } init (start:...
Christophe's user avatar
  • 75.1k
4 votes
1 answer
105 views

I have a simple question about covariance/contravariance here. Below, I have a Func<T1, T2> that I need to be casted to Func<T1, object>. In theory, this should be possible, but in ...
Daniel Möller's user avatar
0 votes
0 answers
26 views

I have relational data, i.e. observations for pairs of objects. More specifically these are migration rates between plant populations, which I would like to explain by a predictor. The migration rates ...
Tobias Naaf's user avatar
Advice
0 votes
8 replies
114 views

The problem I am trying to solve is representing a partially loaded tree of objects using C# generics. For example, suppose we have the following classes: public class Address { public string ...
Jeremy Salwen's user avatar
4 votes
1 answer
141 views

From the official docs: The introduction of explicit syntax for generic classes in Python 3.12 eliminates the need for variance to be specified for type parameters. Instead, type checkers will infer ...
Leonardus Chen's user avatar
2 votes
1 answer
68 views

Method parameters should be contravariant, hence defining a covariant generic should raise a type error. However when using a covariant generic in a union pyright, mypy and pyre-check all do not ...
Daraan's user avatar
  • 5,166
0 votes
0 answers
83 views

I am simulating a system in which I do not have very accurate information about the measurement and process noises (R and Q). However, although my linear Kalman filter works, it seems that there is ...
CURSO EE 1S 2024's user avatar
2 votes
1 answer
92 views

I have the following code. The compiler complains about the last line. I am wondering why. The WrappedFunction case class takes a function object with trait arguments. When I try to construct a ...
user3068137's user avatar
1 vote
0 answers
43 views

Probably there is a duplicate question somewhere but I'm not sure what the correct search terms are. Since a snippet says more than a thousand words: why is this not valid C#? class A<T> { } ...
CompuChip's user avatar
  • 9,252
1 vote
0 answers
50 views

Can any body help me in succesfully typecasting the derived class object which in real application created from Dependency Injection and retrieved from builder.Services. I am typecasting it to base ...
Usman's user avatar
  • 2,900
0 votes
1 answer
69 views

I have tried a number linear regressions, and though the standard ones are all good (e.g., lm.fit is really nicely fast), the fastLM in https://www.rdocumentation.org/packages/RcppEigen/versions/0.3....
ivo Welch's user avatar
  • 3,098
2 votes
2 answers
101 views

I'm working with a union type of two instances of a generic class. These instances have different property shapes, but they also share common properties. I'm encountering an issue when trying to ...
stambolievv's user avatar
1 vote
0 answers
32 views

I think TS fails to warn against an invalid method override. In the following code, Dog extends Animal. But Dog is a consumer of DogFood, a subclass of Food, and Animal is a consumer of Food. So the ...
Tilt's user avatar
  • 41
5 votes
0 answers
98 views

If you have something like this, struct Foo { }; constexpr auto pred = [](){ return Foo{}; }; calling std::not_fn(pred) will fail to compile, expectedly. However, adding an explicit conversion ...
Enlico's user avatar
  • 30.3k
2 votes
1 answer
105 views

Consider the following code snippet: class Animal {} class Dog : Animal {} interface IMyContainer<T> { T Get(int i); void Add (T thing); } class MyList<T> : IMyContainer<T> ...
MukundKS's user avatar
  • 134

15 30 50 per page
1
2 3 4 5
130