Infix and Postfix Logic Operators

Provides adds postfix and infix logic operators for if, then, unless, and otherwise.


postlogic

Travis build status Coverage status

The goal of postlogic is to allow natural flowing logic statements.

Installation

You can install the released version of postlogic from CRAN with:

install.packages("postlogic")

If/Otherwise

The if/otherwise instruction allows for simple logic to follow a statement to make it conditional. The %if% can be used alone to make an action conditional.

verbose <- TRUE 
message("Hello there") %if% verbose

When combined with the %otherwise% statement it allows for an alternate.

mood <- "calm"
message("How dare you!") %if% (mood == 'angry') %otherwise% 
    message("Everything is fine.")
#> Everything is fine.
 
mood <- 'angry'
message("How dare you!") %if% (mood == 'angry') %otherwise% 
    message("Everything is fine.")
#> How dare you!

Unless/Then

The %unless% operator is essentially the negation of %if%. So when a statement is postfixed by an %unless% statement it will happen unless the proposition returns TRUE. The alternating operator for %unless% is %then%.

mood <- 'calm'
message("Everything is fine.") %unless% (mood == 'angry') %then% 
    message("How dare you!")
#> Everything is fine.

This example is the same effect as the statements in the previous example.

Documentation

The postlogic package is developed by the R Documentation Task Force, an R Consortium Infrastructure Steering Committee working group.

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("postlogic")

0.1.0 by Andrew Redd, 5 months ago


https://github.com/RDocTaskForce/postlogic


Report a bug at https://github.com/RDocTaskForce/postlogic/issues


Browse source code at https://github.com/cran/postlogic


Authors: Andrew Redd [aut, cre] (<https://orcid.org/000-0002-6149-2438>)


Documentation:   PDF Manual  


GPL-2 license


Suggests testthat, covr


Imported by Rd, testextra.


See at CRAN