Skip to content

(el)

array elements selected by position and/or value (used with (arr ...))

clojure
(el pos? val?)

Where:

  1. pos: position in the list (1-based) *
  2. val: value at that position *

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: CompositionFree-form SelectionRefinementReplacement

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)

Copyright © 2022-present Semantic Works, Inc.