Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
61 views

I’m really confused about what polymorphism in OOP actually means. Everyone explains it differently, and I’m not sure which definition is correct: In some places, polymorphism is explained as dynamic ...
Ado's user avatar
  • 55
0 votes
1 answer
430 views

Swift newbie here, please be kind! How can I convert this SwiftUI view into a version that accepts different types of items as input? I have this view in my iOS app: struct EditMeshType: View { ...
BaldNomad's user avatar
8 votes
1 answer
274 views

I declared two functions using the 'forall' quantifier. The first of them has a quantifier with all generic type parameters before the signature. The second has quantifiers in place of the first usage ...
Valentyn Zakharenko's user avatar
0 votes
1 answer
64 views

First, setup interface IRequirement { } interface ITarget { ICollection<IRequirement> Requirements { get; set; } } interface IRequirementHandler<TRequirement, TTarget> where ...
mhDuke's user avatar
  • 148
1 vote
0 answers
448 views

I have a struct that has quite a few different fields. Initially, I can use parametric typing for all of the fields. For example: struct MyStruct{TF, TI, TB} a::TF b::TF c::Array{TF, 2} ...
cardoza2's user avatar
  • 185
-1 votes
2 answers
405 views

I'm getting acquainted with the Polymorphism of OOP while making a game in Unity. I try to use an interface that will take part in a damage system. Here is the interface code: using System.Collections;...
BSN's user avatar
  • 1
0 votes
4 answers
837 views

This is me probably going off what is considered idiomatic in Julia, as I am clearly abusing parametric types (generic types instead of hardcoded ones) but I am struggling to understand why this doesn'...
DMeneses's user avatar
  • 159
0 votes
1 answer
70 views

I'm trying to declare a record type that has two entries, one named id that is a string, and another named algorithm that can be any function. According to what I've investigated, I need to use ...
NPN328's user avatar
  • 1,962
1 vote
1 answer
60 views

As I understand now from Array as object I have to use parametric object, because using non-parametric Logtalk objects implies that I have to use assert i.e. any change/set rewrites the whole array. ...
sten's user avatar
  • 7,536
3 votes
1 answer
169 views

I have defined a buggy function: let first : 'a -> 'b -> 'a = fun x y -> y ;; (* Result: val first : 'a -> 'a -> 'a = <fun> *) The compiler accepts it and changes the type from '...
Oleg Dats's user avatar
  • 4,143
0 votes
2 answers
179 views

The answer is: (a -> b) -> (c -> d -> a) -> c -> d -> b But I don't know how to get there.
David Vives's user avatar
3 votes
1 answer
100 views

During some development using cubical-agda, I noticed (and later checked) that my current goal, if proven would also imply such theorem: parametric? : ∀ ℓ → Type (ℓ-suc ℓ) parametric? ℓ = (f : {A : ...
MJG's user avatar
  • 73
6 votes
3 answers
746 views

I am creating a turn based game. I want to define a datatype that encodes one type out of many possible types. Here is the motivating example: I have defined a Turn type using GADTs, so the type of ...
MooseOnTheRocks's user avatar
2 votes
2 answers
268 views

I'm trying to produce a typed Racket procedure that for some type A, takes a Tree, and a function from two As to an A, another parameter of type A, and returns a value of type A. I'm not very familiar ...
Isaac Wasserman's user avatar
4 votes
2 answers
330 views

For a type with parametrically typed fields like: struct Point{T <: AbstractFloat} x::T y::T end How to make an outer constructor that creates default values with the desired types? For ...
BaliSun's user avatar
  • 43
0 votes
1 answer
298 views

I've defined a trait as follows: trait Readable<E> { fn read_u8(&mut self) -> Result<u8, E>; fn read_u16be(&mut self) -> Result<u16, E>; } The idea is to ...
puritii's user avatar
  • 1,359
76 votes
2 answers
30k views

AsRef documentation writes Used to do a cheap reference-to-reference conversion. I understand reference-to-reference part what does it mean by cheap? I hope it has nothing to do with complexity ...
HardFork's user avatar
  • 1,153
0 votes
1 answer
35 views

So if I wanted a method to be common for 3 child classes, like this: public void commonForAllAnimals(Animal animal) { // this method exists in subclasses that I need animal.foo(); // only in Dog ...
developer10's user avatar
  • 1,500
2 votes
1 answer
1k views

I want to work with rings, so I have a trait RingOps and I want float to be a part of it. I think float implements each supertype so deriving would be great, but if not, how to do this? trait RingOps: ...
rausted's user avatar
  • 959
8 votes
3 answers
4k views

I have a struct NotificationOption and another struct NotificationOption2 as well as an implementation for From<NotificationOption> for NotificationOption2. I'm would like to convert Vec<...
Avba's user avatar
  • 15.3k
2 votes
2 answers
1k views

For a function like this: fn generate_even(a: i32, b: i32) -> impl Iterator<Item = i32> { (a..b).filter(|x| x % 2 == 0) } I want to make it generic, instead of the concrete type i32 I ...
tipograf ieromonah's user avatar
0 votes
2 answers
95 views

To clarify what I mean, my issue is with a simulated annealing problem where I want to find the theta that gives me the max area of a shape: def Area(theta): #returns area def SimAnneal(space,func,...
PythonMan1029's user avatar
0 votes
1 answer
113 views

The following code produces the titular error: (: f (∀ (a) (-> [#:x a] (U Integer a)))) (define (f #:x [x #f]) (or x 0)) (f #:x 3) OK, but (f #:x (cast 3 Integer)) still produces the same error. ...
0xnick1chandoke's user avatar
0 votes
1 answer
77 views

Trying to implement a generic Vec implementing the std::ops::Add trait. I want the implementation to automatically convert the underlying type of the vector on addition so I can do something like this:...
Luke Skywalker's user avatar
2 votes
1 answer
50 views

When you define parametric classes you can only use a fixed number of parameters. class Container<T> { ... } However, if you want to create, say, a Map with multiple values. You must use a ...
user avatar

1
2 3 4 5