Counters: Counters

Description Usage Arguments Examples

Description

Counters

Signed increment

Non-negative increment

Usage

1
2
3
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

 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
38
39
40
41
42
43
44
45
## 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 May 1, 2019, 10:53 p.m.