Skip to content

Commit c830246

Browse files
committed
standardized indentation
1 parent 05ec750 commit c830246

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

_posts/2012-12-23-sugar-all.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ src: 2012-12-23-sugar-all.cpp
1010
The sugar function all() answers the question, "Are all of the values ... ?".
1111

1212

13-
1413
The all_sug() function takes a LogicalVector as an argument and allows one to
1514
enter an expression for the argument as shown in the R examples. In this example,
1615
it is simply wrapper around the sugar function all() and includes is_true to
@@ -29,7 +28,6 @@ bool all_sug(LogicalVector x) {
2928
}
3029
{% endhighlight %}
3130

32-
3331
{% highlight r %}
3432
x <- c(3, 9, 0, 2, 7, 5, 6)
3533
y <- c(0, 0, 0, 0, 0, 0, 0)
@@ -78,7 +76,6 @@ all_sug(y == 0)
7876
[1] TRUE
7977
</pre>
8078

81-
8279
While the above function may seem trivial, it can be easy to forget is_true() when
8380
using all() and will result in a compile error. The check_equal() function below
8481
is an example of a simple utility function to check two vectors for equality
@@ -87,17 +84,16 @@ using the all_sug() function defined above.
8784
{% highlight cpp %}
8885
// [[Rcpp::export]]
8986
void check_equal(NumericVector x, NumericVector y) {
90-
if(all_sug(x == y)) {
91-
Rcout << "Success! The input vectors are equal" << std::endl;
92-
// do something
93-
} else {
94-
Rcout << "Fail! The input vectors are not equal" << std::endl;
95-
// do something else
96-
}
87+
if (all_sug(x == y)) {
88+
Rcout << "Success! The input vectors are equal" << std::endl;
89+
// do something
90+
} else {
91+
Rcout << "Fail! The input vectors are not equal" << std::endl;
92+
// do something else
93+
}
9794
}
9895
{% endhighlight %}
9996

100-
10197
{% highlight r %}
10298
check_equal(x, y)
10399
{% endhighlight %}
@@ -119,4 +115,3 @@ check_equal(x, c(3, 9, 0, 2, 7, 5, 6))
119115
<pre class="output">
120116
Success! The input vectors are equal
121117
</pre>
122-

src/2012-12-23-sugar-all.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ all_sug(y == 0)
4444

4545
// [[Rcpp::export]]
4646
void check_equal(NumericVector x, NumericVector y) {
47-
if(all_sug(x == y)) {
48-
Rcout << "Success! The input vectors are equal" << std::endl;
49-
// do something
50-
} else {
51-
Rcout << "Fail! The input vectors are not equal" << std::endl;
52-
// do something else
53-
}
47+
if (all_sug(x == y)) {
48+
Rcout << "Success! The input vectors are equal" << std::endl;
49+
// do something
50+
} else {
51+
Rcout << "Fail! The input vectors are not equal" << std::endl;
52+
// do something else
53+
}
5454
}
5555

5656

0 commit comments

Comments
 (0)