Questions tagged [generic-function]
81 questions
3
votes
1 answer
How to invoke generic function via Selector at runtime in Swift?
I'm trying to register a callback for an UI event at runtime like this.
func observeEvent(event: UIControlEvent){
self.addTarget(self, action: "eventFired:", forControlEvents: event)
}
func eventFired(sender: T){
print("event…

Ryan Ho
- 293
- 1
- 3
- 14
3
votes
1 answer
Anonymous methods in common lisp
I want to save a generic function as a variable:
(defvar *gf* (make-instance 'standard-generic-function)
But when adding a method I have to define call-next-method and next-method-p myself:
(add-method *gf*
(make-instane…

cl-porky11
- 339
- 1
- 11
3
votes
1 answer
Create a delegate of a generic function
I'm writing some unit tests and I have a lot of functions of the form
public void SomeTestHelperMethod(TKey key, TValue value)
which I'm calling repeatedly with various arguments like this
SomeTestHelperMethod(0,…

Bryan Anderson
- 15,969
- 8
- 68
- 83
3
votes
1 answer
C# Generics and Generic Constraints
I'm writing a generic abstract class A with type parameter T that I intend to derive with class B.
A has a data member, mX, an instance of class C, with a generic function. This generic function, GetAllOfType(), has one type parameter, T. This type…

jbarba
- 91
- 4
2
votes
3 answers
Why doesn't a separately instantiated Func predicate not translate into SQL with Entity Framework?
I have an EF Code First Db context that I'm using to query the database. I noticed some performance issues when passing in queries as Funcs from my Aggregate Repository and on investigating further it turned out that the queries were…

Eoin Campbell
- 43,500
- 17
- 101
- 157
2
votes
1 answer
Understanding CLOS :after and primary methods
In the hunchentoot source code, there is an :after defmethod called initalize-instance.
This particular example is one of a handful of :after methods called initalize-instance throughtout the project.
My experience with CLOS taught me that a primary…

Vinn
- 1,030
- 5
- 13
2
votes
1 answer
Abstract method with single-dispatch generic functions
I want to put single-dispatch method in functools module with abstract method in abc module in one method in my abstract class and then using the method in my subclasses
based on first argument type. but the problem is the dispatch method doesn't…

amirhossein
- 27
- 8
2
votes
1 answer
How to use a function from one glue script to another in AWS glue
I have one AWS glue pyspark script for example scriptA.py. In this script I have defined few generic functions like readSourceData()
def readSourceData(parameter1, parameter2):
//logic of function
Now I want to use this generic function in my secong…

Beginner
- 71
- 1
- 3
- 10
2
votes
1 answer
How to write generic function that acts differently depending on passed pandas column dtype
I'm trying to write a generic function using singledispatch from functools. I want the function to behave differently depending on the type of passed argument - in this case, it will be a column of data frame, which can be of different dtype:…

deonardo_licaprio
- 308
- 1
- 11
2
votes
1 answer
Call a generic function passed as parameter in recursive function
My desire is to run a given function by name through AddressOf with one input parameter, e.g. Function Foo(x as Integer) As Integer. The two inputs I need into the recursive function are the function name _name As String and an object of some type t…

pmackni
- 307
- 3
- 12
2
votes
1 answer
how to dispatch summary() method in R6 object
I am using R6 to build an object which fields includes a data frame and other informations.
I defined a first method $print() which I can call as obj1$print() or print(obj1) and both ways works just fine.
> obj1$print()
test object name: AA
>…

frenkg
- 23
- 4
2
votes
0 answers
Making wrapper objects compatible with @singledispatch?
Say I have a class like this:
class Wrapper(object):
def __init__(self, obj):
self.__obj = obj
def __getattr__(self, name):
logger.debug('Accessing %s', name)
return getattr(self.__obj, name)
Elsewhere in the…

Dan Passaro
- 4,211
- 2
- 29
- 33
2
votes
0 answers
Overloading S3 functions with different parameters in R
It is a follow up to the posted question Create a function with different arguments in R
I created a generic function but got stuck with passing different set of parameters to these functions
modelBuild <- function(x, ...) {
…

user11180971
- 43
- 4
2
votes
2 answers
Can't variables be used within generic function methods? (CLOS/LISP)
I'm learning about generic functions in CLOS.
Because of the type of examples I find in textbooks and online, I'm getting very confused. The examples always use the fact that there is multiple dispatch. Based on the argument type, a different…

Kevin Van Ryckegem
- 1,915
- 3
- 28
- 55
2
votes
0 answers
How do I display "X" by entering X, in R?
How can one capture the object name of an argument to a generic function call?
A toy example will clarify the question and, as I understand it, core issue. Consider an object of some S3 class:
X <- structure("blah", class = "SomeClass")
For…

egnha
- 1,157
- 14
- 22