Skip to content

Commit

Permalink
Update example.R
Browse files Browse the repository at this point in the history
Your basic strategy is great, and has been preserved here. However, Jon is keen to encourage the use of native pipes, now they are available (since v4.1.0). More lines, but perhaps better readability than nested functions - especially as the pipeline gets longer.

At Jon's prompting, I wrote this up in an [approaches doc](https://exercism.org/tracks/r/exercises/reverse-string/approaches/native-pipes) about 2 weeks ago. That article includes various useful links.
  • Loading branch information
colinleach authored Feb 1, 2024
1 parent c4cf41c commit e3d24e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion exercises/practice/pop-count/.meta/example.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
egg_count <- function(display_value) {
sum(as.integer(intToBits(display_value)))
display_value |>
intToBits() |>
as.integer() |>
sum()
}

0 comments on commit e3d24e9

Please sign in to comment.