Skip to content

Commit

Permalink
Lab7: Remove spaces in poly exercise.
Browse files Browse the repository at this point in the history
Added bonus exercise for eats macro.
  • Loading branch information
janfrancu committed Nov 11, 2021
1 parent 65a790c commit 90a4230
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/src/lecture_07/lab.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Ideally we would like write some macro `@poly` that takes a polynomial in a math

*Example usage*:
```julia
p = @poly x 3x^2 + 2x^1 + 10x^0 # the first argument being the independent variable to match
p = @poly x 3x^2+2x^1+10x^0 # the first argument being the independent variable to match
```

However in order to make this happen, let's first consider much simpler case of creating the same but without the need for parsing the polynomial as a whole and employ the fact that macro can have multiple arguments separated by spaces.
Expand Down Expand Up @@ -263,7 +263,7 @@ end
Let's test it.
```@repl lab07_poly
using InteractiveUtils #hide
p = @poly x 3x^2 + 2x^1 + 10
p = @poly x 3x^2+2x^1+ 10
p(2) == evalpoly(2, [10,2,3])
@code_lowered p(2) # can show the generated code
```
Expand Down Expand Up @@ -456,6 +456,8 @@ where `Grass => 0.5` defines the behavior of the `eat!` function. The coefficien
end
```

**BONUS**:
You can try running the simulation with the newly added agents.

```@raw html
</div></div>
Expand Down

0 comments on commit 90a4230

Please sign in to comment.