(el)
array elements selected by position and/or value (used with (arr ...))
(el pos? val?)Where:
Behavior
- With only a position,
(el N)matches arrays that have an element at that position. - Without position or value,
(el)only matches non-empty arrays.
Examples
Extract route handlers from [method, path, handler] tuples.
(arr (el 3 (:into)))Selects in lines { 2, 3 } but not in { 4 }:
const routes = [
["GET", "/health", health],
["POST", "/users", createUser],
["GET", "/status"]
]Find arrays that use null as a sentinel in the first slot.
(arr (el 1 (null)))Selects in lines { 1, 3 } but not in { 2 }:
const rows1 = [null, "ready"]
const rows2 = ["ready", null]
const rows3 = [null, "done"]Locate arrays that include the beta flag anywhere in the list.
(arr (el _ (str "beta")))Selects in lines { 1, 3 } but not in { 2 }:
const flags1 = ["beta", "dark-mode"]
const flags2 = ["stable", "dark-mode"]
const flags3 = ["dark-mode", "beta"]Arguments
pos
• Number
Does NOT support: Composition — Free-form Selection — Refinement — Replacement
val
• Identifier: shorthand for (id)
• String: shorthand for (str)
• (:kind) • (:ref) • (:text) • (arr) • (attr) • (bool) • (call) • (child) • (comp) • (export) • (fun) • (id) • (id+) • (import) • (jsx) • (mem) • (null) • (num) • (obj) • (of) • (prop) • (regex) • (regex+) • (str) • (str*) • (str+) • (tpl) • (tpl*) • (var) • (:into) • (:and) • (:or) • (:not) • (:replace) • (:capture)