Skip to content

Commit fa407f0

Browse files
authored
Clarify HW03 text (#19)
1 parent de8c845 commit fa407f0

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

docs/Manifest.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ version = "1.16.1+0"
5757

5858
[[ChainRulesCore]]
5959
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
60-
git-tree-sha1 = "a325370b9dd0e6bf5656a6f1a7ae80755f8ccc46"
60+
git-tree-sha1 = "8d954297bc51cc64f15937c2093799c3617b73e4"
6161
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
62-
version = "1.7.2"
62+
version = "1.10.0"
6363

6464
[[ColorSchemes]]
6565
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random"]
@@ -131,9 +131,9 @@ version = "0.8.5"
131131

132132
[[Documenter]]
133133
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
134-
git-tree-sha1 = "8b43e37cfb4f4edc2b6180409acc0cebce7fede8"
134+
git-tree-sha1 = "769275a95354ef52e5f4b00814249da73d53869e"
135135
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
136-
version = "0.27.7"
136+
version = "0.27.9"
137137

138138
[[DocumenterTools]]
139139
deps = ["AbstractTrees", "Base64", "DocStringExtensions", "Documenter", "FileWatching", "Gumbo", "LibGit2", "Sass"]
@@ -218,9 +218,9 @@ version = "3.3.5+0"
218218

219219
[[GR]]
220220
deps = ["Base64", "DelimitedFiles", "GR_jll", "HTTP", "JSON", "Libdl", "LinearAlgebra", "Pkg", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"]
221-
git-tree-sha1 = "c2178cfbc0a5a552e16d097fae508f2024de61a3"
221+
git-tree-sha1 = "d189c6d2004f63fd3c91748c458b09f26de0efaa"
222222
uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
223-
version = "0.59.0"
223+
version = "0.61.0"
224224

225225
[[GR_jll]]
226226
deps = ["Artifacts", "Bzip2_jll", "Cairo_jll", "FFMPEG_jll", "Fontconfig_jll", "GLFW_jll", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libtiff_jll", "Pixman_jll", "Pkg", "Qt5Base_jll", "Zlib_jll", "libpng_jll"]
@@ -321,9 +321,9 @@ uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
321321
version = "0.13.4"
322322

323323
[[IrrationalConstants]]
324-
git-tree-sha1 = "f76424439413893a832026ca355fe273e93bce94"
324+
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
325325
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
326-
version = "0.1.0"
326+
version = "0.1.1"
327327

328328
[[IterTools]]
329329
git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18"
@@ -550,9 +550,9 @@ version = "8.44.0+0"
550550

551551
[[Parsers]]
552552
deps = ["Dates"]
553-
git-tree-sha1 = "a8709b968a1ea6abc2dc1967cb1db6ac9a00dfb6"
553+
git-tree-sha1 = "98f59ff3639b3d9485a03a72f3ab35bab9465720"
554554
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
555-
version = "2.0.5"
555+
version = "2.0.6"
556556

557557
[[Pixman_jll]]
558558
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
@@ -578,9 +578,9 @@ version = "1.0.15"
578578

579579
[[Plots]]
580580
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "GeometryBasics", "JSON", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs"]
581-
git-tree-sha1 = "6841db754bd01a91d281370d9a0f8787e220ae08"
581+
git-tree-sha1 = "ba43b248a1f04a9667ca4a9f782321d9211aa68e"
582582
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
583-
version = "1.22.4"
583+
version = "1.22.6"
584584

585585
[[Preferences]]
586586
deps = ["TOML"]
@@ -708,9 +708,9 @@ version = "1.0.0"
708708

709709
[[StatsBase]]
710710
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
711-
git-tree-sha1 = "65fb73045d0e9aaa39ea9a29a5e7506d9ef6511f"
711+
git-tree-sha1 = "eb35dcc66558b2dda84079b9a1be17557d32091a"
712712
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
713-
version = "0.33.11"
713+
version = "0.33.12"
714714

715715
[[StructArrays]]
716716
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]

docs/src/lecture_03/hw.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ in your code will cause the automatic evaluation to fail.
3030
Implement a new species `Mushroom` which tricks a sheep into eating it by its
3131
delicious looks but decreases the energy of the sheep by
3232
`size(::Mushroom)*Δenergy(::Sheep)`.
33+
34+
**Note**: The auto-eval system assumes that you have a constructor
35+
`Mushroom(id,size,max_size)` that accepts the three plant fields as arguments
36+
(as implemented e.g. [here](https://github.com/JuliaTeachingCTU/EcosystemCore.jl/blob/359f0b48314f9aa3d5d8fa0c85eebf376810aca6/src/plant.jl#L11-L13)).
3337
```@raw html
3438
</div></div>
3539
```
3640
Your new species should give you results like below
3741
```@repl hw03
3842
s = Sheep(1,2,1,1,1);
39-
m = Mushroom(2,5);
43+
m = Mushroom(2,2,5);
4044
w = World([s,m])
4145
eat!(s,m,w);
4246
w
@@ -70,20 +74,23 @@ simulation.
7074
<header class="admonition-header">Homework (1 point)</header>
7175
<div class="admonition-body">
7276
```
73-
Implement a function `every_nth(f::Function,n::Int)` that takes a function and
74-
uses a closure to construct another function that only calls `f` every `n`
75-
calls to the function `fn` that is returned by `every_nth(f,n)`.
77+
Implement a function `every_nth(f::Function,n::Int)` that takes an inner
78+
function `f` and uses a closure to construct an outer function `g` that only
79+
calls `f` every `n`th call to `g`. E.g. if `n=3` the inner function `f` be called
80+
at the 3rd, 6th, 9th ... call to `g` (not at the 1st, 4th, 7th... call).
7681

82+
**Hint**: You can use splatting via `...` to pass on an unknown number of
83+
arguments from the outer to the inner function.
7784
```@raw html
7885
</div></div>
7986
```
8087
You can use `every_nth` to log (or save) the agent count only every couple of
8188
steps of your simulation. Using `every_nth` will look like this:
8289
```@repl hw03
8390
# `@info agent_count(w)` is executed only every 5th call to logcb(w)
84-
logcb = every_nth(w->(@info agent_count(w)), 5);
91+
logcb = every_nth(w->(@info agent_count(w)), 3);
8592
86-
for i in 1:10
87-
logcb(w)
88-
end
93+
logcb(w); # x->(@info agent_count(w)) is not called
94+
logcb(w); # x->(@info agent_count(w)) is not called
95+
logcb(w); # x->(@info agent_count(w)) *is* called
8996
```

0 commit comments

Comments
 (0)