Skip to content

Commit 41050bf

Browse files
authored
reference: Update control (#201)
* reference: Update control Signed-off-by: Ce Gao <[email protected]> * controlflow: Fix style Signed-off-by: Ce Gao <[email protected]>
1 parent b964bee commit 41050bf

File tree

25 files changed

+71
-335
lines changed

25 files changed

+71
-335
lines changed

examples/reference/binary/.property.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
category: Control
2+
subcategory:
3+
description: "
4+
The binary comparison operators are generic functions: methods can be written for them individually or via the Ops) group generic function.<br />
5+
<br />
6+
Comparison of strings in character vectors is lexicographic within the strings using the collating sequence of the locale in use: see locales. The collating sequence of locales such as en_US is normally different from C (which should use ASCII) and can be surprising. Beware of making any assumptions about the collation order: e.g. in Estonian Z comes between S and T, and collation is not necessarily character-by-character – in Danish aa sorts as a single letter, after z. In Welsh ng may or may not be a single sorting unit: if it is it follows g. Some platforms may not respect the locale and always sort in numerical order of the bytes in an 8-bit locale, or in Unicode code-point order for a UTF-8 locale (and may not sort in the same order for the same language in different character sets). Collation of non-letters (spaces, punctuation signs, hyphens, fractions and so on) is even more problematic.<br />
7+
<br />
8+
Character strings can be compared with different marked encodings.<br />
9+
<br />
10+
Raw vectors should not really be considered to have an order, but the numeric order of the byte representation is used.<br />
11+
<br />
12+
At least one of x and y must be an atomic vector, but if the other is a list R attempts to coerce it to the type of the atomic vector: this will succeed if the list is made up of elements of length one that can be coerced to the correct type.<br />
13+
<br />
14+
If the two arguments are atomic vectors of different types, one is coerced to the type of the other, the (decreasing) order of precedence being character, complex, numeric, integer, logical and raw.<br />
15+
<br />
16+
Missing values (NA) and NaN values are regarded as non-comparable even to themselves, so comparisons involving them will always result in NA. Missing values can also result when character strings are compared and one is not valid in the current collation locale.<br />
17+
<br />
18+
Language objects such as symbols and calls are deparsed to character strings before comparison.<br />
19+
"
20+
syntax: "x < y\nx > y\nx <= y\nx >= y\nx == y\nx != y"
21+
parameters:
22+
- label: 'x, y'
23+
description: "atomic vectors, symbols, calls, or other objects for which methods have been written."

examples/reference/break/.property.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/reference/continue/.property.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
category: Control
2+
subcategory:
3+
description: "
4+
break breaks out of a for, while or repeat loop; control is transferred to the first statement outside the inner-most loop. next halts the processing of the current iteration and advances the looping index. Both break and next apply only to the innermost of nested loops.<br />
5+
<br />
6+
Note that it is a common mistake to forget to put braces ({ .. }) around your statements, e.g., after if(..) or for(....). In particular, you should not have a newline between } and else to avoid a syntax error in entering a if ... else construct at the keyboard or via source. For that reason, one (somewhat extreme) attitude of defensive programming is to always use braces, e.g., for if clauses.<br />
7+
<br />
8+
The seq in a for loop is evaluated at the start of the loop; changing it subsequently does not affect the loop. If seq has length zero the body of the loop is skipped. Otherwise the variable var is assigned in turn the value of each element of seq. You can assign to var within the body of the loop, but this will not affect the next iteration. When the loop terminates, var remains as a variable containing its latest value.<br />
9+
"
10+
syntax: "if(cond) expr\nif(cond) cons.expr else alt.expr\n\nfor(var in seq) expr\nwhile(cond) expr\nrepeat expr\nbreak\nnext\n"
11+
parameters:
12+
- label: 'cond'
13+
description: "A length-one logical vector that is not NA. Conditions of length greater than one are currently accepted with a warning, but only the first element is used. An error is signalled instead when the environment variable _R_CHECK_LENGTH_1_CONDITION_ is set to true. Other types are coerced to logical if possible, ignoring any class."
14+
- label: 'var'
15+
description: "A syntactical name for a variable."
16+
- label: 'seq'
17+
description: "An expression evaluating to a vector (including a list and an expression) or to a pairlist or NULL. A factor value will be coerced to a character vector."
18+
- label: 'expr, cons.expr, alt.expr'
19+
description: "An expression in a formal sense. This is either a simple expression or a so called compound expression, usually of the form { expr1 ; expr2 }."
20+
related:
21+
- for
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
for (i in 1:5) print(1:i)
2+
for (n in c(2, 5, 10, 20, 50)) {
3+
x <- stats::rnorm(n)
4+
cat(n, ": ", sum(x^2), "\n", sep = "")
5+
}
6+
f <- factor(sample(letters[1:5], 10, replace = TRUE))
7+
for (i in unique(f)) print(i)

examples/reference/else/.property.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/reference/equality/.property.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/reference/floatconvert/.property.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/reference/greaterthan/.property.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)