search for: unary

Displaying 20 results from an estimated 329 matches for "unary".

2017 Mar 17
3
Support for user defined unary functions
I agree there is no reason they _need_ to be the same precedence, but I think SPECIALS are already have the proper precedence for both unary and binary calls. Namely higher than all the binary operators (except for `:`), but lower than the other unary operators. Even if we gave unary specials their own precedence I think it would end up in the same place. `%l%` <- function(x) tail(x, n = 1) %l% 1:5 #> [1] 5 %l% -5...
2017 Mar 17
2
Support for user defined unary functions
...is proposal and as you noted probably better served by a native operator with different precedence. I think the main benefit to providing user defined prefix operators is it allows package authors to experiment with operator ideas and gauge community interest. The current situation means any novel unary semantics either need to co-opt existing unary operators or propose changes to the R parser, neither of which is ideal for experimentation. The user defined pipe operator (%>%), now used by > 300 packages, is an example that giving package authors the power to experiment can produce benefici...
2017 Mar 16
4
Support for user defined unary functions
R has long supported user defined binary (infix) functions, defined with `%fun%`. A one line change [1] to R's grammar allows users to define unary (prefix) functions in the same manner. `%chr%` <- function(x) as.character(x) `%identical%` <- function(x, y) identical(x, y) %chr% 100 #> [1] "100" %chr% 100 %identical% "100" #> [1] TRUE This seems a natural extension of the existing fun...
2008 Mar 13
2
Making custom unary operators in R
Hello, Is there a way to define a custom unary operator in R (other than making a class and 'overloading' the normal unary operators in R)? The documentation seems to suggest that only custom binary operators are possible with the ``%abc%``construct but I was wondering whether any one has done so. None of the RSiteSearch or RSeek...
2017 Mar 17
2
Support for user defined unary functions
...On Fri, Mar 17, 2017 at 6:46 AM, Gabriel Becker <gmbecker at ucdavis.edu> wrote: > Jim, > > One more note about precedence. It prevents a solution like the one you > proposed from solving all of the problems you cited. By my reckoning, a > "What comes next is for NSE" unary operator needs an extremely low > precedence, because it needs to greedily grab "everything" (or a large > amount) that comes after it. Normal-style unary operators, on the other > hand, explicitly don't want that. > > From what I can see, your patch provides support fo...
2017 Mar 17
0
Support for user defined unary functions
Jim, One more note about precedence. It prevents a solution like the one you proposed from solving all of the problems you cited. By my reckoning, a "What comes next is for NSE" unary operator needs an extremely low precedence, because it needs to greedily grab "everything" (or a large amount) that comes after it. Normal-style unary operators, on the other hand, explicitly don't want that. >From what I can see, your patch provides support for the latter but not...
2017 Mar 16
2
Support for user defined unary functions
Gabe, The unary functions have the same precedence as normal SPECIALS (although the new unary forms take precedence over binary SPECIALS). So they are lower precedence than unary + and -. Yes, both of your examples are valid with this patch, here are the results and quoted forms to see the precedence. `%chr%`...
2017 Mar 17
2
Support for user defined unary functions
...t would give you the > ability to partially evaluate the captured formula/expression, without fully > doing so. See the roxygen comments in Hadley and Lionel's rlang package > here: https://github.com/hadley/rlang/blob/master/R/tidy-unquote.R > > The desired precedence of such a unary operator is not clear to me. The way > rlang implements the !! now, it is quite low, so in the examples you see > there the ~list(!! x + x) is transformed to ~list(10), not ~list(5+x) as I > would have expected. I'm confused by this given what I understand the > purpose to be, but...
2011 Nov 03
1
[LLVMdev] Why there is no unary operator in LLVM?
Hi llvmdev, I've noticed that there is no unary operator in LLVM. For unary operator such as Neg or Or operator, the IR builder just creates a binary operation with one dummy operand, 01823 <http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html#a073c092ce74a122e898e435e60e84599> BinaryOperator <http://llvm.org/doxygen/classllvm_1_1B...
2017 Mar 17
0
Support for user defined unary functions
...at the tilde does not, it would give you the ability to partially evaluate the captured formula/expression, without fully doing so. See the roxygen comments in Hadley and Lionel's rlang package here: https://github.com/hadley/rlang/blob/master/R/tidy-unquote.R The desired precedence of such a unary operator is not clear to me. The way rlang implements the !! now, it is quite low, so in the examples you see there the ~list(!! x + x) is transformed to ~list(10), not ~list(5+x) as I would have expected. I'm confused by this given what I understand the purpose to be, but that probably just m...
2017 Mar 16
2
Support for user defined unary functions
.... > > One could also argue that the user defined infix operators are also > ugly and could be replaced by `f(a, b)` calls as well; beauty is in > the eye of the beholder. > > The unquote example [1] shows one example where this gap in tooling > caused authors to co-opt existing unary exclamation operator, this > same gap is part of the reason the formula [2] and question mark [3] > operators have been used elsewhere in non standard contexts. > > If the language provided package authors with a native way to create > unary operators like it already does for the oth...
2011 Dec 16
3
[LLVMdev] llvm/clang test failures on powerpc-darwin8
Hi, Thanks for the quick reply again. > On Thu, Dec 15, 2011 at 1:17 PM, David Fang <fang at csl.cornell.edu> wrote: >> Hi, >> >> I've bootstrapped llvm/clang from svn-trunk on powerpc-darwin8 (g++-4.0.1), and >> have the following test results to share. >> Summary below, full log at: >>
2017 Mar 17
0
Support for user defined unary functions
Bill, Right. My example was the functional form for clarity. There is a desire for a unary-operator form. (rlang's !! and !!! operators described in the comments in the file I linked to). I can't really make that argument because I'm not one of the people who wanted that. You'd have to talk to the authors of the rlang package to find out their reasons for thinking that i...
2017 Mar 16
0
Support for user defined unary functions
>>>>> Jim Hester <james.f.hester at gmail.com> >>>>> on Thu, 16 Mar 2017 12:31:56 -0400 writes: > Gabe, > The unary functions have the same precedence as normal SPECIALS > (although the new unary forms take precedence over binary SPECIALS). > So they are lower precedence than unary + and -. Yes, both of your > examples are valid with this patch, here are the results and quoted > forms...
2017 Mar 16
2
Support for user defined unary functions
.... Best, ~G On Thu, Mar 16, 2017 at 9:51 AM, Martin Maechler <maechler at stat.math.ethz.ch > wrote: > >>>>> Jim Hester <james.f.hester at gmail.com> > >>>>> on Thu, 16 Mar 2017 12:31:56 -0400 writes: > > > Gabe, > > The unary functions have the same precedence as normal SPECIALS > > (although the new unary forms take precedence over binary SPECIALS). > > So they are lower precedence than unary + and -. Yes, both of your > > examples are valid with this patch, here are the results and quoted...
2005 Jan 07
1
Creating unary operators
Is it correct (by its lack of mention in the R-Language Definition Manual) that it is impossible to create a user-defined unary operator? Ex: (This doesn't work, but it's an example of what I'm looking for) > "%PLUSONE%" <- function(x) x + 1 > %PLUSONE% 2 [1] 3 And if the above is impossible, am I limited to only the + - ~ ! unary operators for overloading? On the same vein, is it correct...
2017 Mar 16
0
Support for user defined unary functions
I am biased against introducing new syntax, but if one is experimenting with it one should make sure the precedence feels right. I think the unary and binary minus-sign operators have different precedences so I see no a priori reason to make the unary and binary %xxx% operators to be the same. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Mar 16, 2017 at 3:18 PM, Michael Lawrence <lawrence.michael at gene.com> wrote: > I gue...
2017 Mar 16
0
Support for user defined unary functions
...ed functional and infix operators. One could also argue that the user defined infix operators are also ugly and could be replaced by `f(a, b)` calls as well; beauty is in the eye of the beholder. The unquote example [1] shows one example where this gap in tooling caused authors to co-opt existing unary exclamation operator, this same gap is part of the reason the formula [2] and question mark [3] operators have been used elsewhere in non standard contexts. If the language provided package authors with a native way to create unary operators like it already does for the other operator types these...
2003 Mar 13
1
apply() and unary operators
...[,2] [1,] 1 3 [2,] 2 4 > apply(a,2,sum) [1] 3 7 > apply(a,2,"+") [,1] [,2] [1,] 1 3 [2,] 2 4 > apply(a,1,"+") [,1] [,2] [1,] 1 2 [2,] 3 4 > help(apply) says that "+" should be quoted but is otherwise silent on unary operators. I don't understand apply() here at all. anyone? -- Robin Hankin, Lecturer, School of Geography and Environmental Science Tamaki Campus Private Bag 92019 Auckland New Zealand r.hankin at auckland.ac.nz tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042
2012 Oct 30
4
Error unary operator
...et(foo, Rayos != "Rayos.NA"), aes(x=HTL, y=DevelopIndex, colour=TotalEggs)) +geom_point() +geom_jitter() + facet_grid(Aeventexhumed ~ Rayos) + geom_smooth(method="lm", fill=NA) + ylim(c(0, 7)) Error in +geom_smooth(method = "lm", fill = NA) : invalid argument to unary operator [[alternative HTML version deleted]]