%=>% {dipsaus}R Documentation

A JavaScript style of creating functions

Description

A JavaScript style of creating functions

Usage

args %=>% expr

Arguments

args

function arguments: see formals

expr

R expression that forms the body of functions: see body

Value

A function that takes args as parameters and expr as the function body

Examples

# Formal arguments
c(a) %=>% {
  print(a)
}

# Informal arguments
list(a=) %=>% {
  print(a)
}

# Multiple inputs
c(a, b = 2, ...) %=>% {
  print(c(a, b, ...))
}

# ----- JavaScript style of forEach -----
# ### Equivalent JavaScript Code:
# LETTERS.forEach((el, ii) => {
#   console.log('The index of letter ' + el + ' in "x" is: ' + ii);
# });

iapply(LETTERS, c(el, ii) %=>% {
  cat2('The index of letter ', el, ' in ', sQuote('x'), ' is: ', ii)
}) -> results

[Package dipsaus version 0.2.9 Index]