Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update episodes from Literate.jl source files #106

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 85 additions & 1 deletion episodes/02_Getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,28 @@ help?> ∂
Great! This way she can easily look up the names she needs.
She gets back to normal mode by pressing <kbd>backspace</kbd>.

:::::: challenge

## Exploring Julia's Help Mode

Help mode can also be used to look up the documentation for Julia functions.
Use Julia's help mode to read the documentation for the `varinfo()` function.

:::::: solution

## Solution


::::::

If you are not already in help mode, type `?` to enter it. Then write `varinfo` and press enter.

```julia
?varinfo
```

::::::

Another useful mode is the *shell mode* that can be
entered by pressing <kbd>;</kbd>. The prompt has now changed:

Expand All @@ -167,7 +189,69 @@ Like before, hit <kbd>backspace</kbd> to get back to the Julia prompt.

:::::: challenge

## Hello, `shell>` !
## Hello, `shell>` (`pwd` and `cd`) !

Two commonly used shell commands are `pwd` (**p**rint **w**orking **d**irectory) and `cd` (**c**hange **d**irectory).

1. Use `pwd` to find out what is your current working directory.
2. Type the command `cd` in shell mode, which by default will bring you to your "home directory".
3. Use `pwd` again. Did you get a different result from before? Why or why not?

:::::: solution

## Solution

```julia
shell> pwd
```

```julia
shell> cd
```

```julia
shell> pwd
```

::::::

The working directory is the location from which you launched Julia.
To navigate to a different directory, you can use the `cd` command by entering: `cd <directory>`. By default, this command will return you to your home directory if a specific directory is not given.
If you initially launched Julia from your home directory, the working directory remains unchanged, so the output of the second `pwd` command will be identical to the first.
Conversely, if you were in a different directory when you started Julia, the results of the two `pwd` commands will differ.
You can use `cd -` to go back to your previous location.

::::::

:::::: challenge

## Hello, `shell>` (`ls`)!

Another useful shell command is `ls` (*list files*).
Use it to show the contents of your home directory.

:::::: solution

## Solution

```julia
shell> cd
```

```julia
shell> ls
```

::::::

The first `cd` command will bring you to your home directory.
`ls` will print a list of the files and directorys in your current location.

::::::

:::::: challenge

## Hello, `shell>` (`nano` and `cat`)!

Use the shell mode to create a file called `hello.jl` with the nano terminal text editor.
Inside that file write the simple hello world program `print("Hello World!")`.
Expand Down
2 changes: 1 addition & 1 deletion episodes/04_Using_the_package_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ environment.
````
Status `~/projects/trebuchet/Project.toml`
[f6369f11] ForwardDiff v0.10.38
[295af30f] Revise v3.6.2
[295af30f] Revise v3.6.3
[98b73d46] Trebuchet v0.2.2

````
Expand Down
30 changes: 15 additions & 15 deletions episodes/07_Loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ Trebuchet( rand() * 500, rand() * pi/2 )

````output
2-element Trebuchet:
301.45863866265444
0.5147801124901857
228.38576259167743
1.0428133782844782
````

will give her a Trebuchet with a weight between 0 and 500 and a release angle between 0 and pi/2 radians at random.
Expand All @@ -121,9 +121,9 @@ distances = [shoot_distance(Trebuchet(rand() * 500, rand() * pi / 2), env) for _

````output
3-element Vector{Float64}:
107.31486215571258
116.5961233156913
3.006112235174449
75.81435701587722
83.01842049268829
67.14411448705451
````

This is called an _array comprehension_.
Expand All @@ -138,16 +138,16 @@ distances = [(w,a) => shoot_distance(Trebuchet(w, a), env) for (w, a) in zip(wei

````output
10-element Vector{Pair{Tuple{Float64, Float64}, Float64}}:
(316.3006668666567, 0.2763285950708336) => 101.94306047739477
(184.81067380921974, 0.21663020097625554) => 87.01600131363767
(118.28342636599143, 0.16251023948500737) => 71.41041926553547
(495.4627412106457, 0.2337213045007839) => 100.84254397856022
(121.54718006057836, 1.2933538749770221) => 44.31450096256152
(50.49083319279707, 1.3999293689100087) => 18.58057814648708
(463.0506320312314, 0.32643937336190937) => 108.22484752113716
(296.1556297915833, 0.035353940515857406) => 62.1859221237384
(134.340007097649, 1.2511802453356395) => 51.71612933008983
(493.7526856775179, 0.5068383250394274) => 118.81200975980546
(3.3334597480246253, 0.7838682352298685) => 0.6815707596179541
(210.78228935379622, 1.381946534840864) => 35.85286633327975
(401.5993709331619, 0.2185755446723246) => 96.9029165112703
(174.8500444474639, 1.3802675063026215) => 34.83498096430634
(459.5195474131575, 0.6388081196321991) => 117.62925382680423
(325.9792258612826, 1.4742042308383514) => 23.118879918525415
(424.04535348026496, 0.13367159006587603) => 84.32898973441384
(367.203106692998, 0.6088354356429886) => 117.46105246416498
(12.984772128024124, 1.5235451260228559) => 0.6815707596179541
(10.485349585032166, 0.6353974863672037) => 0.6815707596179541
````

### Gradient descent
Expand Down
2 changes: 1 addition & 1 deletion episodes/10_Adding_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
````

````output
Test.DefaultTestSet("Test arithmetic equalities", Any[], 1, false, false, true, 1.731584626736792e9, 1.731584626767338e9, false)
Test.DefaultTestSet("Test arithmetic equalities", Any[], 1, false, false, true, 1.731669987513481e9, 1.731669987543832e9, false)
````

With this Melissa can run her test using the pkg mode of the REPL:
Expand Down