Pipes in Julia
|> feeds left to right; dotted pipes broadcast the chain.
targets = ["m42", " m31 ", "M13", "m45 "]
# |> feeds a value to the next function, left to right.
cleaned = targets .|> strip .|> uppercase
println(cleaned)
count_bright = cleaned |> unique |> length
println("$count_bright unique targets")
# Compose with \circ-free syntax: a small chain of named steps.
normalize(s) = uppercase(strip(s))
label(s) = "NGC queue: $s"
println(" m57 " |> normalize |> label)
How it works
targets .|> strip .|> uppercasecleans every element.cleaned |> unique |> lengthreads as a sentence.- Small named steps keep chains debuggable.
The run, in numbers
- Lines
- 13
- Characters to type
- 410
- Tokens
- 77
- Three-star pace
- 65 tpm
At the three-star pace of 65 tokens a minute, this run takes about 71 seconds.
Step 1 of 3 in Idioms, step 19 of 27 in Language basics.