(el) - JavaScript
array elements selected by position and/or value (used with (arr ...))
clojure
(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.
clojure
(arr (el 3 (:into)))Selects in lines { 2, 3 } but not in { 4 }:
typescript
const routes = [
["GET", "/health", health],
["POST", "/users", createUser],
["GET", "/status"]
]Find arrays that use null as a sentinel in the first slot.
clojure
(arr (el 1 (null)))Selects in lines { 1, 3 } but not in { 2 }:
typescript
const rows1 = [null, "ready"]
const rows2 = ["ready", null]
const rows3 = [null, "done"]Locate arrays that include the beta flag anywhere in the list.
clojure
(arr (el _ (str "beta")))Selects in lines { 1, 3 } but not in { 2 }:
typescript
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