Questions tagged [generic-function]

81 questions
0
votes
1 answer

Generic function called via second argument of foo(x, bar) in R

I want to make a generic function predict() for 'foo' class in R so that it is invoked when second argument of predict() is of class 'foo': class(y.foo) <- "foo" predict(x, y.foo) Is it possible? How to do it?
Tim
  • 7,075
  • 6
  • 29
  • 58
0
votes
2 answers

Checking nulls for the generic types

I wanted to create a function, which will check the value of the parameter, if it's null it should set the value based on type of the parameter, else it should just return the value as it is.Here what i have tried. public static T ConvertNull(T…
Abbas
  • 4,948
  • 31
  • 95
  • 161
0
votes
2 answers

How to turn these functions generic

I wanted to shorten my code, since i`m having more functions like this. I was wondering if I could use getattr() to do something like this guy asked. Well, here it goes what I`ve got: def getAllMarkersFrom(db, asJSON=False): '''Gets all markers…
cesarvargas
  • 182
  • 3
  • 15
-1
votes
1 answer

singledispatch on unpacked multiple arguments

I have a fancyfunction defined to do something to a single argument. I decorate it to become a generic function so that it knows what to do if it is given a tuple. from functools import singledispatch @singledispatch def fancyfunction(arg): …
Kit
  • 30,365
  • 39
  • 105
  • 149
-1
votes
1 answer

swift generic func with overlapping type constraints

I have this protocol hierarchy: protocol A {} protocol B: A {} what will happen if I have the 2 following funcs: func myFunc( object: T){ ... } func myfunc( object: T){ ... } Which function will be executed if I call…
t4ncr3d3
  • 615
  • 1
  • 8
  • 17
-3
votes
1 answer

How can I change the arguments in my generic function plot?

Why my code is not working, correctly. How can I pass, properly, the argument hist.args = NULL, plot.args = NULL to the function plot and hist inside the plot.gevp function? plot.gevp=function (vector, type = c("predictive", "retlevel"), t,…
aliocha
  • 5
  • 3
1 2 3 4 5
6