similar to: How do I reliably and efficiently hash a function?

Displaying 20 results from an estimated 11000 matches similar to: "How do I reliably and efficiently hash a function?"

2015 Dec 11
1
How do I reliably and efficiently hash a function?
In addition to what Charles wrote, you can also use 'local' if you don't want a function that creates another function. > f <- local({info <- 10; function(x) x + info}) > f(3) [1] 13 best, Mark Op vr 11 dec. 2015 om 03:27 schreef Charles C. Berry <ccberry at ucsd.edu>: > On Thu, 10 Dec 2015, Konrad Rudolph wrote: > > > I?ve got the following scenario:
2015 Dec 11
0
How do I reliably and efficiently hash a function?
On Thu, Dec 10, 2015 at 5:49 PM, Konrad Rudolph <konrad.rudolph+r-devel at gmail.com> wrote: > I?ve got the following scenario: I need to store information about an > R function, and retrieve it at a later point. In other programming > languages I?d implement this using a dictionary with the functions as > keys. In R, I?d usually use `attr(f, 'some-name')`. However, for
2015 Dec 11
0
How do I reliably and efficiently hash a function?
On Thu, 10 Dec 2015, Konrad Rudolph wrote: > I?ve got the following scenario: I need to store information about an > R function, and retrieve it at a later point. In other programming > languages I?d implement this using a dictionary with the functions as > keys. In R, I?d usually use `attr(f, 'some-name')`. However, for my > purposes I do not want to use `attr` because the
2006 Aug 09
3
objects and environments
Dear list, I have two functions created in the same environment, fun1 and fun2. fun2 is called by fun1, but fun2 should use an object which is created in fun1 fun1 <- function(x) { ifelse(somecondition, bb <- "o", bb <- "*") ## mymatrix is created, then myresult <- apply(mymatrix, 1, fun2) } fun2 <- function(idx) { if (bb == "o) { #
2011 Apr 07
2
Two functions as parametrs of a function.
Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1<-unlist(par1) p2<-unlist(par2) force(p1) force(p2)
2012 Nov 08
5
map two names into one
Thanks. Yes. Your approach can identify: Glaxy ace S 5830 and S 5830 Glaxy ace But you can not identify using same program: Iphone 4S 16 G Iphone 4S 16G How should I solve both in same time. Kind regards,Tammy [[alternative HTML version deleted]]
2004 Mar 25
1
mlocal/mtrace inside a loop
Hello I need some help in figuring Bravington’s debugger out. Ok I have 2 functions, fun1 and fun2 saved in a ASCII file say filename is funs. Fun1 has a loop which calls fun2, fun2 has a loop which fails and I need to find out the value of the variables of the fun2 and fun1 loops at the specific iteration that fails. Both fun1 and fun2 loops will iterate thousands of times so line by line debug
2009 Oct 01
1
pass "..." to multiple sub-functions
Dear list, I know I have seen this discussed before but I haven't been successful in searching for "ellipsis", "dots", "..." in the archives. I would like to filter "..." arguments according to their name, and dispatch them to two sub-functions, say fun1 and fun2. I looked at lm() but it seemed more complicated than I need as it modifies the calling
2016 Oct 02
5
On implementing zero-overhead code reuse
I'm looking for a way to approximate the "zero-overhead" model of code reuse available in languages like Python, Perl, etc. I've described this idea in more detail, and the motivation for this question in an earlier post to R-help (https://stat.ethz.ch/pipermail/r-help/2016-September/442174.html). (One of the responses I got advised that I post my question here instead.) The
2012 Aug 30
1
How to modify the values of the parameters passing via ...
Dear Friends, Let's assume there are three parameters that were passed into fun1. In fun1, we need to modify one para but the remains need to be untouched. And then all parameters were passed into fun2. However, I have failed to achieve it. Please see the following code. ########################################## fun1 <-function(x, y, z=10) {x+y+z;} fun2 <-function(aa, ...) {
2012 Nov 20
2
correct function formation in R
Dear list! ? I have question of?'correct function formation'. Which function (fun1 or fun2; see below) is written more correctly? Using ''structure'' as output or creating empty ''data.frame'' and then transform it as output? (fun1 and fun1 is just for illustration). ? Thanks a lot, OV ? code: input <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 =
2012 Nov 17
3
transform input argument (matrix) of function
Dear list!   I would like to write a function to transform matrix, which is input argument of a written function. It is easy with new matrix (see below), but my idea is to transform input argument (matrix) of function without any additional matrixes. Here is an example: fun1 <- function(xy) { xy <- cbind(xy[,1], xy[,2], xy[,1] + xy[,2]) return(xy) }   df1 <- matrix(c(1,2,3,1,2,3), ncol =
2014 Jan 25
1
package NAMESPACE question
Hello, I'm building a package. My code is stored in foo.R. This code has two functions FUN1 and FUN2. FUN1 calls FUN2. FUN1 is listed in export() under the package NAMESPACE but NOT FUN2. After building the package when I call FUN1 is giving me an error that cannot find FUN2. I solved this by adding FUN2 in the export() NAMESPACE. However, what is puzzling me is that I have other examples
2006 Aug 16
1
Problem with the special argument '...' within a function
I'm not sure if this is what you want, but simply add ... to the list of arguments for fun1 and fun2 would eliminate the error. Andy From: Hans-Joerg Bibiko > > Dear all, > > I wrote some functions using the special argument '...'. OK, it works. > > But if I call such a function which also called such a > function, then I get an error message about unused
2015 Feb 24
2
iterated lapply
> On Feb 24, 2015, at 10:50 AM, <luke-tierney at uiowa.edu> wrote: > > The documentation is not specific enough on the indented semantics in > this situation to consider this a bug. The original R-level > implementation of lapply was > > lapply <- function(X, FUN, ...) { > FUN <- match.fun(FUN) > if (!is.list(X)) > X <-
2002 Aug 01
6
update() can not find objects (PR#1861)
Full_Name: Yi-Xiong Zhou Version: 1.5.1 OS: win2000pro Submission from: (NULL) (64.169.249.42) Update() can not find objects when it is used in a function, which is in turn being called by another function. Here is a R script to show the problem: ######## begin of the test script ########## fun1 <- function() { x <- matrix(rnorm(500), 20,25) y <- rnorm(20) oo <- lm(y~x)
2004 Mar 23
3
how to modify variables of another frame (but not global)
Hello! Maybe "frame" is not the right term in this context. I explain my problem by example code: fun2 <- function(objName, add) { ## the object "objName" should be increased by "add", ## but the evaluation should be done in the calling function (here: fun1) ## ...... what's the right code?? } fun1 <- function() { x <- 1 fun2("x",
2010 Aug 11
2
storing the results of an apply call
Hi R-users, I have a function (myfun) that I want to apply to the rows of a matrix. Basically, "myfun" takes the values from the matrix ("exp.des"), which represent the different combinations of my experimental design, and pass them as arguments to some other functions (fun1 and fun2). As I want to replicate the results of fun1 and fun2 a certain number of time (e.g. 5), I
2009 May 01
1
integrate with large parameters
Dear R-users, i have to integrate the following function `fun1` <- function (a, l1, l2) { exp(log(l1) * (a - 1) - l2 * lgamma(a)) } but if l1 is large, i get the "non-finite function value" error, so my idea is to rescale with exp(-l1) `fun2` <- function (a, l1, l2) { exp(log(l1) * (a - 1) - l2 * lgamma(a) - l1) } but it seems this doesn't solve the problem, when
2017 Apr 30
1
`match.call` and dots substitution
I'm noticing some interesting behavior in `match.call` in some corner-ish cases that arise when you try to use `match.call` to match a "grandparent" function and there are dots involved: fun0 <- function(a, ...) fun1(...) fun1 <- function(b, ...) fun2() fun2 <- function() match.call( fun1, sys.call(sys.parent()), expand.dots=FALSE,