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

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
import REPL.REPLCompletions: completions, complete_path, completion_text, Completion, ModuleCompletion
331 μs
👀 Reading hidden code
import REPL.REPLCompletions
187 μs
description (generic function with 6 methods)
👀 Reading hidden code
begin
description(x::Function) = "Function"
description(x::Number) = "Number"
description(x::AbstractString) = "String"
description(x::Module) = "Module"
description(x::AbstractArray) = "Array"
description(x::Any) = "Any"
end
1.4 ms
👀 Reading hidden code
names(@__MODULE__, all=false, imported=true)
4.3 ms
f (generic function with 1 method)
👀 Reading hidden code
f((a,b)::Tuple{String,Int}) = a
620 μs
"a"
👀 Reading hidden code
f(("a",3))
11.5 μs
false
👀 Reading hidden code
startswith("nameof(m)", "workspace")
12.3 μs
Error message

Multiple definitions for f

Combine all definitions into a single reactive cell using a `begin ... end` block.

f() = [try description(getfield(c.parent, Symbol(c.mod))) catch; "" end for c in cs]
👀 Reading hidden code
---

👀 Reading hidden code
66.6 μs
import LinearAlgebra
👀 Reading hidden code
235 μs
import PlutoUI
👀 Reading hidden code
64.2 ms
Error message

type DataType has no field mutable

Stack trace

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

  1. getproperty(x::Type, f::Symbol)
    from Base.jl:37
  2. PlutoUI.Button.mutable
PlutoUI.Button.mutable
👀 Reading hidden code
---
Error message

MethodError: no method matching sort(::Base.Iterators.Zip{Tuple{Vector{Int64}, Vector{Int64}}})

Closest candidates are:

sort(::AbstractUnitRange) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/range.jl:1304

sort(::AbstractRange) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/range.jl:1307

sort(::SparseArrays.SparseVector{Tv, Ti}; kws...) where {Tv, Ti} at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/stdlib/v1.7/SparseArrays/src/sparsevector.jl:1968

...

Stack trace

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

  1. sort(zip([1,2], [3,4]))
sort(zip([1,2], [3,4]))
👀 Reading hidden code
---
Error message

Multiple definitions for f

Combine all definitions into a single reactive cell using a `begin ... end` block.

Everything is going to be okay!
f() = [try getfield(c.parent, Symbol(c.mod)) catch; end for c in cs]
👀 Reading hidden code
---
123
aaa = 123
👀 Reading hidden code
11.8 μs
Error message

`a` is not a recognized command. Type ? for help with available commands

Stack trace

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

  1. pkgerror(msg::String)
  2. (::Pkg.REPLMode.var"#13#14")(words::Vector{Pkg.REPLMode.QString})
  3. iterate
  4. grow_to!(dest::Vector{Pkg.REPLMode.Statement}, itr::Base.Generator{Base.Iterators.Filter{Base.var"#84#85"{typeof(isempty)}, Vector{Vector{Pkg.REPLMode.QString}}}, Pkg.REPLMode.var"#13#14"})
  5. collect
  6. parse
  7. do_cmd(repl::Pkg.REPLMode.MiniREPL, input::String; do_rethrow::Bool)
  8. Pkg.pkg"a"
Pkg.pkg"a"
👀 Reading hidden code
The Pkg REPL mode is intended for interactive use only, and should not be used from scripts. It is recommended to use the functional API instead.
---
@bind query html"<input>"
👀 Reading hidden code
222 ms
Error message

Another cell defining cs contains errors.

hcat([HSL(x*360, 0.5, 0.5) for x in hashes])'
👀 Reading hidden code
---
names (generic function with 1 method)
names
👀 Reading hidden code
11.1 μs
Error message

MethodError: no method matching lastindex(::Missing)

Closest candidates are:

lastindex(::Any, ::Any) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/abstractarray.jl:373

lastindex(::NamedTuple) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/namedtuple.jl:125

lastindex(::AbstractArray) at /opt/hostedtoolcache/julia/1.7.3/x64/share/julia/base/abstractarray.jl:372

...

Stack trace

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

  1. cs = completions(query, lastindex(query), @__MODULE__)[1]
C'est la vie !
cs = completions(query, lastindex(query), @__MODULE__)[1]
👀 Reading hidden code
---
Error message

Another cell defining cs contains errors.

modulecs = filter(c -> c isa REPLCompletions.ModuleCompletion, cs)
👀 Reading hidden code
---
Error message

Another cell defining cs contains errors.

completed_modules = Set(c.parent for c in cs if c isa REPLCompletions.ModuleCompletion)
👀 Reading hidden code
---
Error message

Another cell defining cs contains errors.

completed_modules_exports = Dict(m => string.(names(m, all=false, imported=false)) for m in completed_modules)
👀 Reading hidden code
---
Error message

Another cell defining cs and completed_modules contains errors.

Be patient :)
filter(modulecs) do c
c.mod ∈ completed_modules_exports[c.parent]
end
👀 Reading hidden code
---
Error message

Another cell defining cs contains errors.

uhmmmmmm??!
fav = last(cs)
👀 Reading hidden code
---
Error message

Another cell defining cs contains errors.

completions_exported(cs)
👀 Reading hidden code
---
completions_exported (generic function with 1 method)
function completions_exported(cs::Vector{<:Completion})
completed_modules = Set(c.parent for c in cs if c isa ModuleCompletion)
completed_modules_exports = Dict(m => string.(names(m, all=false, imported=false)) for m in completed_modules)

map(cs) do c
c isa ModuleCompletion && c.mod ∈ completed_modules_exports[c.parent]
end
end
👀 Reading hidden code
2.7 ms
Error message

Another cell defining cs contains errors.

c_texts = completion_text.(cs)
👀 Reading hidden code
---

👀 Reading hidden code
65.7 μs
begin
import Pkg
Pkg.add("Colors")
using Colors
end
👀 Reading hidden code
❔
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `~/.julia/environments/v1.7/Project.toml`
  [5ae59095] + Colors v0.13.1
    Updating `~/.julia/environments/v1.7/Manifest.toml`
  [5ae59095] + Colors v0.13.1
2.1 s
Error message

Another cell defining cs contains errors.

hashes = Float64.(hash.(c_texts)) ./ Float64(typemax(UInt))
👀 Reading hidden code
---
true
first("α") |> islowercase
👀 Reading hidden code
14.4 ms
completion_priority (generic function with 1 method)
function completion_priority(s::String)
c = first(s)
if islowercase(c)
1
elseif isuppercase(c)
2
else
3
end
end
👀 Reading hidden code
573 μs
Error message

Another cell defining cs contains errors.

You got this!
sort(c_texts, alg=MergeSort, by=completion_priority)
👀 Reading hidden code
---
Error message

syntax: incomplete: premature end of input

LinearAlgebra.
👀 Reading hidden code
---

odl

md"""
# odl
"""
👀 Reading hidden code
204 μs
Error message

syntax: extra token "requests" after end of expression

ffox

165 requests
2.67 MB / 2.67 MB transferred
Finish: 27.57 s
DOMContentLoaded: 2.25 s
load: 7.46 s

👀 Reading hidden code
---
Error message

syntax: extra token "requests" after end of expression

Oh no! 🙀
chrome

168 requests
224 kB transferred
4.3 MB resources
Finish: 1.60 s
DOMContentLoaded: 1.21 s
Load: 1.41 s
👀 Reading hidden code
---

without cache

md"""
## without cache
"""
👀 Reading hidden code
227 μs
Error message

syntax: extra token "requests" after end of expression

ffox

171 requests
4.12 MB / 4.13 MB transferred
Finish: 13.84 s
DOMContentLoaded: 1.45 s
load: 14.20 s
👀 Reading hidden code
---
Error message

syntax: extra token "requests" after end of expression

chrome

173 requests
2.6 MB transferred
4.3 MB resources
Finish: 21.49 s
DOMContentLoaded: 1.36 s
Load: 1.55 s
👀 Reading hidden code
---

new

md"""
# new
"""
👀 Reading hidden code
215 μs
Error message

syntax: extra token "requests" after end of expression

¯\_(ツ)_/¯
ffox

75 requests
2.68 MB / 2.68 MB transferred
Finish: 5.55 s
DOMContentLoaded: 1.60 s
load: 5.56 s
👀 Reading hidden code
---
Error message

syntax: extra token "requests" after end of expression

chrome

81 requests
224 kB transferred
4.3 MB resources
Finish: 1.38 s
DOMContentLoaded: 822 ms
Load: 963 ms
👀 Reading hidden code
---

no cache

md"""
## no cache
"""
👀 Reading hidden code
219 μs
Error message

syntax: extra token "requests" after end of expression

ffox

84 requests
4.14 MB / 4.14 MB transferred
Finish: 7.13 s
DOMContentLoaded: 1.58 s
load: 7.33 s
👀 Reading hidden code
---
Error message

syntax: extra token "requests" after end of expression

chrome

81 requests
2.6 MB transferred
4.3 MB resources
Finish: 2.64 s
DOMContentLoaded: 1.57 s
Load: 1.84 s
👀 Reading hidden code
---