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
tic = Ref(time())
15.7 μs
👀 Reading hidden code
Enter cell code...
78.6 μs
1.1583960056304932
👀 Reading hidden code
let
x
toc = time()
Δt = toc - tic[]
tic[] = toc
end
44.9 μs
missing
👀 Reading hidden code
12.2 μs
👀 Reading hidden code
@bind x html"""
<canvas id="drawboard" width="200" height="200"></canvas>

<script>
const canvas = document.querySelector("canvas#drawboard")
const ctx = canvas.getContext("2d")

var startX = 80
var startY = 40

function sendvalue() {
// 🐸 This is how we send the value back to Julia 🐸 //
const raw = ctx.getImageData(0,0,200,200).data
canvas.value = raw.buffer
canvas.dispatchEvent(new CustomEvent("input"))
}

function onmove(e){
ctx.fillStyle = '#ffecec'
ctx.fillRect(0, 0, 200, 200)
ctx.fillStyle = '#3f3d6d'
ctx.fillRect(startX, startY, e.layerX - startX, e.layerY - startY)

sendvalue()
}

canvas.onmousedown = e => {
278 ms
endswith (generic function with 7 methods)
begin
import Base: endswith
function endswith(vec::Vector{T}, suffix::Vector{T}) where T
local liv = lastindex(vec)
local lis = lastindex(suffix)
liv >= lis && (view(vec, (liv-lis + 1):liv) == suffix)
end
end
👀 Reading hidden code
984 μs
false
endswith([1,2,3], [2,3, 4, 5])
👀 Reading hidden code
24.2 μs
Error message

syntax: missing last argument in "2:" range expression

view([1,2,3], 2:end) == [2,3]
👀 Reading hidden code
---

👀 Reading hidden code
70.8 μs
Error message

MethodError: no method matching append!(::String, ::String)

Closest candidates are:

append!(::BitVector, ::Any) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/bitarray.jl:782

append!(::AbstractVector, ::Any) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/array.jl:1050

append!(::AbstractVector, ::Any...) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/array.jl:1053

Stack trace

Here is what happened, the most recent locations are first:

  1. 	str = "asdfasdfdfas"	append!(str, "xx")end
Oh no! 🙀
begin
str = "asdfasdfdfas"
append!(str, "xx")
end
👀 Reading hidden code
---
Error message

Another cell defining str contains errors.

uhmmmmmm??!
codeunits(str)|> Vector{UInt8}
👀 Reading hidden code
---
using JSON
👀 Reading hidden code
87.1 ms
Error message

Another cell defining str contains errors.

obj = Dict(:a => Dict(:b => str), :c => :d)
👀 Reading hidden code
---
Error message

Another cell defining str contains errors.

JSON.Parser.parse( codeunits(JSON.json(obj)) |> Vector{UInt8} |> String) |> length
👀 Reading hidden code
---