Skip to content
Prev 175698 / 398503 Next

Variable Wildcard Value

Hi,

Since you insist, here is something that I think matches the 
specifications :

wildcard <- function( ) structure( NULL, class = "wildcard" )
Ops.wildcard <- function (e1, e2){
    if (nargs() == 1L)
        return( e1 )
    result <- switch(.Generic,
        `<` = , `>` = , `==` = ,
        `<=` = , `>=` = TRUE, `!=` = FALSE)
    result
}
is.na.wildcard <- function( x ) FALSE


 > w == 1
[1] TRUE
 > w == "peanut butter"
[1] TRUE
 > is.na( w )
[1] FALSE
 > "peanut butter" == w
[1] TRUE
 > w == w
[1] TRUE
 > w != w
[1] FALSE

# Is negation of a wildcard also a wildcard, or should it be a bizarro 
wildcard ?
 > (!w) == 2
[1] TRUE


Not really sure how this could be useful though, and would also be 
interested in Francis end game.

Romain
Patrick Burns wrote: