Skip to content

Commit

Permalink
Merge branch 'master' into clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
sadda committed May 10, 2021
2 parents 4b5674c + 8a23e7e commit 79fd892
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/src/lecture_01/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ julia> split(str)
"language!"
```

By default, the function splits the given string based on spaces. This can be changed by defining a delimiter.
By default, the function splits the given string based on whitespace characters. This can be changed by defining a delimiter.

```jldoctest joins
julia> split(str, " a ")
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lecture_06/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Now we use `add Colors` to install the Colors package.
Since we want to work in `scripts`, we change the environment back.

```julia
(ImageInspector) pkg> activate /scripts
(ImageInspector) pkg> activate ./scripts

(scripts)
```
Expand Down
6 changes: 2 additions & 4 deletions docs/src/why.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ We do not check whether the input argument is a non-negative integer for simplic

```python
def fib(n):
if n<2:
return n
return fib(n-1) + fib(n-2)
return n if n<2 else fib(n-1) + fib(n-2)
```

Finally, an implementation in C would be close to:
Expand All @@ -65,7 +63,7 @@ int fib(int n) {
}
```
We see that these three implementations are very different. Surprisingly, the implementation in C is the shortest one. The reason is that C allows using the [ternary operator](https://en.wikipedia.org/wiki/%3F:). Even though Matlab allows to write the `if-else` statement on one line, this would decrease the code readability. Julia can implement this function in a simple way.
We see that these three implementations are very different. Surprisingly, the implementation in C is the shortest one on par with python. The reason is that C allows using the [ternary operator](https://en.wikipedia.org/wiki/%3F:). Even though Matlab allows to write the `if-else` statement on one line, this would decrease the code readability. Julia can implement this function in a simple way.
```julia
fib(n::Int) = n < 2 ? n : fib(n-1) + fib(n-2)
Expand Down

0 comments on commit 79fd892

Please sign in to comment.