getIfCond: Accessor functions for elements of 'if' language objects

View source: R/findFunctionDefs.R

getIfCondR Documentation

Accessor functions for elements of if language objects

Description

Typically, these are not needed as the user/programmer knows the structure of the if language objects. They hide the details when introducing meta-programming.

isIfFalse determines whether the condition is a literal FALSE value and so the code within the if body will never be evaluated.

Usage

getIfCond(code)
getIfTrue(code)
getIfFalse(code)

Arguments

code

the R language object

Value

The relevant language objects.

Author(s)

Duncan Temple Lang

See Also

findCallsTo

Examples

 e = quote(if(all(x < 0)) {
               sum(log(abs(x)))
           } else if(any(x == 0)) {
              x[ x == 0 ] = rnorm(sum(x == 0), sd = 0.001)
           } else {
              sum(log(x))
           })
  getIfCond(e)

  fa = getIfFalse(e)
  getIfCond(fa)
  getIfTrue(fa)
  getIfFalse(fa)

duncantl/CodeAnalysis documentation built on Feb. 21, 2024, 10:49 p.m.