File: if-otherwise.Rd

package info (click to toggle)
r-cran-postlogic 0.1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 112 kB
  • sloc: sh: 13; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
\name{if-otherwise}
\alias{if-otherwise}
\alias{\%if\%}
\alias{\%otherwise\%}
\title{Postfix if-otherwise logic}
\usage{
prior \%if\% proposition

prior \%if\% proposition \%otherwise\% alternate
}
\arguments{
\item{prior}{The value to be returned if proposition evaluates to TRUE.}

\item{proposition}{The logical statement to evaluate}

\item{alternate}{The value to be returned if proposition evaluates to FALSE.}

\item{prior \%if\% proposition}{An \code{\%if\%} statement.}
}
\description{
This construction allows logical statements to be placed after the value to be returned.
Take note that the `%if%` and `%otherwise%` operators follow the same order of operations
as other custom infix operators and so care should be taken that the effect is as desired.
}
\examples{
    x <- 1
    x <- (x+1) \%if\% is.numeric(x) \%otherwise\% "Hmm this isn't right O.o"
    x # 2

    x <- 1i
    x <- (x+1) \%if\% is.numeric(x) \%otherwise\% "Hmm this isn't right O.o"
    x # Hmm this isn't right
}
\seealso{
Other postlogic: \code{\link{unless-then}}
}
\concept{postlogic}