Counters: Counters

CountersR Documentation

Counters

Description

Counters

Signed increment

Non-negative increment

Usage

counter %+-% increment

counter %++% increment

Arguments

counter

If counter and increment are both (signed/positive) integers counter will change by the value of increment.

increment

An integer value \neq 0 to add to counter

Examples

## Not run: 
# Signed increment
# Notice the difference between passing an object and a value for counter

# Value
(10 %+-% -5)
(10 %+-% -5)

# Object
i <- 10
(i %+-% -5)
(i %+-% -5)

# This means we can use the infix in a while ... statement
# WARNING: As is the case for any while ... statement, be careful not to create an infinite loop!

i <- 10
while(i > -5){
  i %+-% -5
  print(i)
}


# Non-negative increment
# Notice the difference between passing an object and a value for counter

# Value
(0 %++% 5)
(0 %++% 5)

# Object
i <- 0
(i %++% 5)
(i %++% 5)

# This means we can use the infix in a while ... statement
# WARNING: As is the case for any while ... statement, be careful not to create an infinite loop!

i <- 0
while(i < 20){
i %++% 5
print(i)
}

## End(Not run)


invctr documentation built on Aug. 16, 2022, 5:18 p.m.