In the following, let’s define sum as
sum = function (a, b, c) a + b +cBecause base::sum’s definition involves ..., which would make the following explanation unnecessarily complex.
In the following, let’s define sum as
sum = function (a, b, c) a + b +cBecause base::sum’s definition involves ..., which would make the following explanation unnecessarily complex.
![screenshot][]
In the following we will be using R’s “restarts” feature to implement the state machine that drives generators in languages such as Python. Generators allow lazily generating values on demand: a consumer invokes a generator, and consumes values as they are produced. A new value is only produced once the previous one has been consumed.
Your test data:
text = 'created_date start_date
2014-12-11 2014-12-10
2014-12-11 2014-12-11| # Higher order function that returns a function: | |
| make_sum = function () { | |
| # Some code here … | |
| message('Requesting to calculate a sum') | |
| sum | |
| } | |
| seq(1, 10) %>% sum | |
| # Now, logically, what does this do? |
| inline int f() { | |
| static int x = 0; | |
| return ++x; | |
| } | |
| static int g() { | |
| static int x = 0; | |
| return ++x; | |
| } |
| #!/usr/bin/env bash | |
| # Configuration | |
| # The remote target branch name needs to be | |
| # 1. DIFFERENT from the local development branch | |
| # 2. Set as the default branch name on GitHub | |
| remote_target_branch=master | |
| generated_contents_dir=_site | |
| get-working-branch() { |
| # Example makefile with some dummy rules | |
| .PHONY: all | |
| ## Make ALL the things; this includes: building the target, testing it, and | |
| ## deploying to server. | |
| all: test deploy | |
| .PHONY: build | |
| # No documentation; target will be omitted from help display | |
| build: |
| #!/usr/bin/env bash | |
| # Inspired by <http://blog.melski.net/2010/11/30/makefile-hacks-print-the-value-of-any-variable/> | |
| usage() { | |
| echo >&2 "Usage: $0 [-f makefile] variables..." | |
| echo >&2 | |
| echo >&2 "Optional arguments:" | |
| echo >&2 " -f makefile: path to the makefile" | |
| echo >&2 |
| # Dummy object, only required for name resolution. | |
| set = structure(list(), class = 'set') | |
| print.set = function (x, ...) invisible(x) | |
| `[.set` = function (set, expr, filter) { | |
| expr = substitute(expr) | |
| filter = substitute(filter) | |
| stopifnot(identical(expr[[1]], quote(`<-`))) | |
| stopifnot(identical(expr[[2]][[1]], quote(`|`))) |