[R-gregmisc-users] SF.net SVN: r-gregmisc: [1228] trunk/gtools/R/oddeven.R
Brought to you by:
warnes
From: <wa...@us...> - 2007-11-30 18:05:45
|
Revision: 1228 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1228&view=rev Author: warnes Date: 2007-11-30 10:05:43 -0800 (Fri, 30 Nov 2007) Log Message: ----------- Update defnitions of odd() and even() to use modulus operator instead of division. Prettier, I think, :-D Modified Paths: -------------- trunk/gtools/R/oddeven.R Modified: trunk/gtools/R/oddeven.R =================================================================== --- trunk/gtools/R/oddeven.R 2007-11-09 22:45:58 UTC (rev 1227) +++ trunk/gtools/R/oddeven.R 2007-11-30 18:05:43 UTC (rev 1228) @@ -1,5 +1,5 @@ # $Id$ # detect odd/even integers -odd <- function(x) x!=as.integer(x/2)*2 -even <- function(x) x==as.integer(x/2)*2 +odd <- function(x) x %% 2 == 1 +even <- function(x) x %% 2 == 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |