Corrections for Ranges chapter.
This commit is contained in:
@@ -320,7 +320,7 @@ In this example, we use the fact that `rem(k, 7)` returns the remainder found fr
|
|||||||
sum(k for k in 1:100 if rem(k,7) == 0) ## add multiples of 7
|
sum(k for k in 1:100 if rem(k,7) == 0) ## add multiples of 7
|
||||||
```
|
```
|
||||||
|
|
||||||
The same `if` can be used in a comprehension. For example, this is an alternative to `filter` for identifying the numbers divisble by `7` in a range of numbers:
|
The same `if` can be used in a comprehension. For example, this is an alternative to `filter` for identifying the numbers divisible by `7` in a range of numbers:
|
||||||
|
|
||||||
|
|
||||||
```{julia}
|
```{julia}
|
||||||
@@ -330,7 +330,7 @@ The same `if` can be used in a comprehension. For example, this is an alternativ
|
|||||||
#### Example: Making change
|
#### Example: Making change
|
||||||
|
|
||||||
|
|
||||||
This example of Stefan Karpinski comes from a [blog](http://julialang.org/blog/2016/10/julia-0.5-highlights) post highlighting changes to the `Julia` language with version `v"0.5.0"`, which added features to comprehensions that made this example possible.
|
This example of Stefan Karpinski's comes from a [blog](http://julialang.org/blog/2016/10/julia-0.5-highlights) post highlighting changes to the `Julia` language with version `v"0.5.0"`, which added features to comprehensions that made this example possible.
|
||||||
|
|
||||||
|
|
||||||
First, a simple question: using pennies, nickels, dimes, and quarters how many different ways can we generate one dollar? Clearly $100$ pennies, or $20$ nickels, or $10$ dimes, or $4$ quarters will do this, so the answer is at least four, but how much more than four?
|
First, a simple question: using pennies, nickels, dimes, and quarters how many different ways can we generate one dollar? Clearly $100$ pennies, or $20$ nickels, or $10$ dimes, or $4$ quarters will do this, so the answer is at least four, but how much more than four?
|
||||||
@@ -506,7 +506,7 @@ Does vector addition work? as expected? In particular, is the result of `(1:4) +
|
|||||||
yesnoq(true)
|
yesnoq(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
What if parenthese are left off? Explain the output of `1:4 + 2:5`?
|
What if parentheses are left off? Explain the output of `1:4 + 2:5`?
|
||||||
|
|
||||||
|
|
||||||
```{julia}
|
```{julia}
|
||||||
|
|||||||
Reference in New Issue
Block a user