You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/lecture_06/hw.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Homework 6: Find variables
2
-
Following the lab exercises, you may thing that metaprogramming is a fun little exercise. Let's challenge this notion in this homework, where *YOU* are being trusted with catching all the edge cases in a AST.
2
+
Following the lab exercises, you may thing that metaprogramming is a fun little exercise. Let's challenge this notion in this homework, where *YOU* are being trusted with catching all the edge cases in an AST.
3
3
4
4
## How to submit?
5
5
Put the code of the compulsory task inside `hw.jl`. Zip only this file (not its parent folder) and upload it to BRUTE. Your file should not use any 3rd party dependency.
@@ -18,8 +18,8 @@ return a tuple of *unique sorted symbols* representing variables in an expressio
18
18
(:x, :y, :z, :c)
19
19
```
20
20
Implement this in a function called `find_variables`. Note that there may be some edge cases that you may have to handle in a special way, such as
21
-
- variable assignments
22
-
- ignoring symbols representing function calls
21
+
- variable assignments`r = x*x` should return `r` as well
22
+
- ignoring symbols representing function calls such as `log`, `exp`, etc.
Create a function that replaces each of `+`, `-`, `*` and `/` with the corresponding checked operation, which checks for overflow. E.g. `+` should be replaced by `Base.checked_add`.
43
+
Create a function that replaces each of `+`, `-`, `*` and `/` with the respective checked operation, which checks for overflow. E.g. `+` should be replaced by `Base.checked_add`.
44
44
45
45
```@raw html
46
46
</div></div>
47
+
<details class = "solution-body" hidden>
48
+
<summary class = "solution-header">Solution:</summary><p>
0 commit comments