Partial application fixes some arguments of a function and returns a new function that accepts the remaining arguments. In Julia, this turns reusable configuration into callable functions: fixing a delimiter creates a splitter, while fixing a predicate creates a filter-ready function. section 15.3.3
The technique fits naturally with closures and the pipe operator. A closure remembers fixed values, and the resulting one-argument function can participate in a readable data flow such as splitting, mapping, and joining. section 15.3.2 section 15.8
Build a camel-case pipeline
Define single-argument methods that fix the delimiter and mapping function, then compose them with |>: import Base: split, map split(dlm::Char) = s -> split(s, dlm) map(fn::Function) = xs -> map(fn, xs) function camel_case(s) s |> split('_') |> map(uppercasefirst) |> join end The same pattern appears in endswith(".png"), which returns a reusable predicate for filter, and in endswith(".png")("truck.png"), which returns true. section 15.3.3
Create reusable cipher functions
Fix a Caesar-cipher shift to obtain an encryptor or decryptor: encrypt = caesar_encrypt(1) encrypt("ABC") # "BCD" A partially applied function can then be placed directly in a pipeline: "HELLO" |> caesar_encrypt(2) |> caesar_decrypt(2) returns "HELLO". Substitution ciphers use the same design, fixing a character mapping instead of a shift. section 15.7.1 section 15.7.2
Listing 15.5 Camel case with partial application
import Base: split, map #1
split(dlm::Char) = s -> split(s, dlm) #2
map(fn::Function) = xs -> map(fn, xs) #3
function camel_case(s)
s |> split('_') |> map(uppercasefirst) |> join
end
Inspect the complete camel-case implementation, including the methods that fix arguments and return closures. section 15.3.3









