Skip to content

Commit 9fa87f0

Browse files
committed
Misc mostly autogenerated files
I don’t know why these are even in the repository, but now I am committing the changes…
1 parent 33000d9 commit 9fa87f0

13 files changed

+1005
-37
lines changed

03_scope_and_closures.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ The function `eval` changes both scope and environment at the same time, but con
103103

104104
## Environment chains, scope, and function calls
105105

106-
When you call a function in R, you first create an environment for that function. That environment is where its parameters will be stored and any local variables the function assigns to will go there as well. That environment is linked to another environment. If the function is defined inside another function it will be the environment in that function instantiation; if the function is called directly from the outermost level, it will be linked to the global environment. Depending on how the function is defined, there might be many such linked environment, and it is this chain of environments that determines the scope used to find a variable and get its value.
107-
108106
When you call a function in R, you first create an environment for that function. That environment is where its parameters will be stored and any local variables the function assigns to will go there as well. That environment is linked to another environment. If the function is defined inside another function it will be the environment in that function instantiation; if the function is called directly from the outermost level, it will be linked to the global environment. Depending on how the function is defined there might be many such linked environment and it is this chain of environments that determines the scope used to find a variable and get its value.
109107

110108
We need another example to see this in action.
@@ -121,7 +119,7 @@ When I have need for more complex chain graphs I will use a graphical notation a
121119

122120
![Environment chain graph](figures/environment-chain-graph){#fig:environment-chain-graph}
123121

124-
If we assume that there are no variables in the global environment when we start the program, we have the global environment `[]`. After we evaluate the first expression, the definition of function `f`, we have changed the global environment, so it now maps `"f` to that function.
122+
If we assume that there are no variables in the global environment when we start the program, we have the global environment `[]`.^[The global environment is actually a little more complex than the empty one we use here. It is nested inside environments where imported packages live. But for the purpose of this chapter, we do not need to worry about that.] After we evaluate the first expression, the definition of function `f`, we have changed the global environment, so it now maps `"f` to that function.
125123

126124
```
127125
["f -> function(x) 2 * x]

07_conclusions.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ We have seen how we can use linked lists (“next lists” in the terminology I
1313

1414
I will end the book here, but I hope it is not the end of your exploration of functional programming in R.
1515

16+
If you liked this book, why not check out my [list of other books](http://wp.me/P9B2l-DN) or
17+
[sign up to my mailing list](http://eepurl.com/cwIbR5)?
18+
19+
1620
## Acknowledgements
1721

1822
I would like to thank Duncan Murdoch and the people on the R-help mailing list for helping me work out a kink in lazy evaluation in the trampoline example.
5.25 MB
Binary file not shown.
4.89 MB
Loading

Functional_programming_in_R.itmsp/metadata.xml

+521
Large diffs are not rendered by default.

Makefile

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
BUILD_DIR := gen
2+
3+
PANDOC := pandoc
4+
5+
PANDOC_OPTS_ALL := -S --toc \
6+
--chapters \
7+
--filter pandoc-fignos
8+
PANDOC_PDF_OPTS := $(PANDOC_OPTS_ALL) \
9+
--default-image-extension=pdf \
10+
--variable links-as-notes \
11+
--template=templates/latex-template.tex
12+
PANDOC_EPUB_OPTS := $(PANDOC_OPTS_ALL) \
13+
--default-image-extension=png \
14+
-t epub3 --toc-depth=1 \
15+
--epub-cover-image=cover.png
16+
17+
#CHAPTERS := 000_header.md \
18+
06_point_free_programming.md \
19+
07_conclusions.md
20+
21+
CHAPTERS := 000_header.md \
22+
00_Introduction.md \
23+
01_functions_in_R.md \
24+
02_pure_functional_programming.md \
25+
03_scope_and_closures.md \
26+
04_higher_order_functions.md \
27+
05_filter_map_and_reduce.md \
28+
06_point_free_programming.md \
29+
07_conclusions.md
30+
31+
32+
book.pdf: pdf_book.md templates/latex-template.tex
33+
$(PANDOC) $(PANDOC_PDF_OPTS) -o $@ pdf_book.md
34+
35+
book.epub: ebook.md
36+
$(PANDOC) $(PANDOC_EPUB_OPTS) -o $@ ebook.md
37+
38+
book.mobi: book.epub
39+
./kindlegen book.epub -o book.mobi
40+
41+
pdf_book.md: $(CHAPTERS) Makefile
42+
cat $(CHAPTERS) | gpp -DPDF > pdf_book.Rmd
43+
./runknitr.sh pdf_book.Rmd
44+
rm pdf_book.Rmd
45+
46+
ebook.md: $(CHAPTERS) Makefile
47+
cat $(CHAPTERS) | gpp -DEPDF > ebook.Rmd
48+
./runknitr.sh ebook.Rmd
49+
rm ebook.Rmd
50+
51+
all: book.pdf book.epub book.mobi
52+
53+
%.md: %.Rmd
54+
./runknitr.sh $<
55+
56+
clean:
57+
rm book.pdf book.epub book.mobi pdf_book.Rmd ebook.Rmd
58+
rm pdf_book.md ebook.md
59+

0 commit comments

Comments
 (0)