To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

This notebook takes about 20 seconds to run.

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
slider = html"<input type='range'>"
1.9 ms

Experiment 1

👀 Reading hidden code
165 μs

Uncomment:

👀 Reading hidden code
184 μs
👀 Reading hidden code
# md"""Last value of $(@bind x slider) was $(x)"""
7.7 μs

Oh oh... it's stuck in an infinite loop! Why this happens is not important right now, but notice that the value is always missing, even in the second iteration.

👀 Reading hidden code
256 μs
👀 Reading hidden code
Enter cell code...
67.3 μs

We create our own slider so that observable/stdlib doesn't send the initial value.

👀 Reading hidden code
175 μs
👀 Reading hidden code
slider_without_initial = html"""
<span>

<input type='range'>

<script>
const span = this.currentScript.parentElement
const input = span.querySelector("input")

input.oninput = (e) => {
span.value = input.value
span.dispatchEvent(new CustomEvent("input"))
e.stopPropagation()
}
</script>
</span>
""";
40.4 μs

This cell depends on z, so it will run when z is set.

z is set to the new value before the cell is executed (by the @bind system), but not when the cell is first run (the bond doesn't exist yet, so z is just an undefined variable).

👀 Reading hidden code
247 μs

Last value of was missing

begin
local wow = missing
try wow = z catch end
output = md"""Last value of $(@bind z slider_without_initial) was $(wow)"""
end
👀 Reading hidden code
254 ms

👀 Reading hidden code
66.6 μs