Association list operations, homed on the Assoc class.
An assoc is one dotted (key . val) pair; an alist is a list of assocs. Keys compared with eq?.
The get/has?/del/put/keys bootstrap globals remain in x/core/alist (the object
system runs on them); these methods delegate to that layer.
AssocPersistent association lists: every operation returns a NEW alist, the input untouched.
The verb rule (#358): persistent operations carry bare verbs (put/del) because nothing mutates; the mutating twins live on Dict with the bang (set!/del!). Same data shape, opposite update models – pick by whether callers share the structure.
(Assoc get key alist)Look up a key in an alist, returning its value or nil.
Parameters:
SYMBOL — Key to look upLIST — Association listReturns: ANY — Value associated with key, or nil if not found
(Assoc get-or d key alist)Look up a key in an alist, returning a default only when the key is absent.
Presence-based: a stored nil is returned as-is, not replaced by the default.
Delegates to the option-store walker, so a flat plist is also accepted.
Parameters:
ANY — Default value if key is absentSYMBOL — Key to look upLIST — Association listReturns: ANY — Value associated with key, or the default
(Assoc has? key alist)Test whether a key exists in an alist.
Parameters:
SYMBOL — Key to checkLIST — Association listReturns: BOOL — True if key is present
(Assoc del key alist)Remove all entries for a key from an alist.
Parameters:
SYMBOL — Key to removeLIST — Association listReturns: LIST — Alist without the given key
(Assoc put key val alist)Set a key-value pair, replacing any existing entry for that key.
Parameters:
SYMBOL — Key to setANY — Value to associateLIST — Association listReturns: LIST — Alist with the key set to val
(Assoc keys alist)Return all keys from an alist.
Parameters:
LIST — Association listReturns: LIST — List of keys
(Assoc vals alist)Return all values from an alist.
Parameters:
LIST — Association listReturns: LIST — List of values
(Assoc map f alist)Apply a function to every value in an alist, preserving keys.
Block form: (Assoc map (x) body … alist) – or (i x) for the 0-based index, then the element.
Parameters:
CALLABLE — Function applied to each valueLIST — Association listReturns: LIST — New alist with transformed values
(Assoc filter pred alist)Keep only assocs satisfying a predicate.
Block form: (Assoc filter (p) body … alist) – or (k v) for the key and the value.
Parameters:
CALLABLE — Predicate: (assoc) -> bool, applied to each (key . val) assocLIST — Association listReturns: LIST — Filtered alist
(Assoc merge a b)Merge two alists; keys in the first take priority.
Parameters:
LIST — Base alist (takes priority)LIST — Alist to merge inReturns: LIST — Merged alist; entries in a shadow those in b
(Assoc pick keys alist)Select entries whose keys appear in a given list.
Parameters:
LIST — List of keys to keepLIST — Association listReturns: LIST — Alist containing only the selected keys
(Assoc omit keys alist)Remove entries whose keys appear in a given list.
Parameters:
LIST — List of keys to excludeLIST — Association listReturns: LIST — Alist without the excluded keys
(Assoc from-bindings bindings)Convert a bindings list into an alist of (key . val) assocs.
Parameters:
LIST — Bindings list: ((key value) …) two-element lists, the let shapeReturns: LIST — Association list
(Assoc ->bindings alist)Convert an alist into a bindings list of (key value) two-element lists.
Parameters:
LIST — Association listReturns: LIST — Bindings list
(Assoc from-plist plist)Convert a flat plist into an alist of assocs.
Parameters:
LIST — Flat (k v k v …) plistReturns: LIST — Association list
Examples:
(Assoc from-plist (list 'a 1)) => (('a . 1))(Assoc ->plist alist)Convert an alist into a flat (k v k v …) plist.
Parameters:
LIST — Association listReturns: LIST — Plist
(Assoc evolve fns alist)Apply per-key transform functions to values in an alist.
Parameters:
LIST — Alist of key -> transform functionLIST — Association list to transformReturns: LIST — Alist with selected values transformed
(Assoc entry key alist)The (key . value) entry itself, by identity (eq?), or nil – the presence-unambiguous entry door (a hit is always a pair); get is the value door. Was (List assq), #357.
Parameters:
ANY — Key to search for, compared with eq?LIST — Association listReturns: ANY — The matching entry pair, or nil
Examples:
(Assoc entry 'b (list (pair 'a 1) (pair 'b 2))) => ('b . 2)(Assoc find key alist)The (key . value) entry itself, by equality (equal?), or nil. String and number keys hit here and miss the eq?-keyed doors (get/entry). Was (List assoc), #357.
Parameters:
ANY — Key to search for, compared with equal?LIST — Association listReturns: ANY — The matching entry pair, or nil
Examples:
(Assoc find "b" (list (pair "a" 1) (pair "b" 2))) => ("b" . 2)(Assoc opt-get-or d key store)Look up a key in an option store (alist or plist); return a default if absent.
Parameters:
ANY — Default value if key is absentSYMBOL — Key to look upLIST — Option store: alist or flat plistReturns: ANY — Stored value, or the default
Examples:
(Assoc opt-get-or 0 'b '(a 1)) => 0(Assoc opt-get-or-else thunk key store)Like opt-get-or but the default is lazy: thunk runs only when the key is absent.
Block form: (Assoc opt-get-or-else () body … key store) – the body is the default, run only on a miss.
Parameters:
CALLABLE — Nullary function producing the defaultSYMBOL — Key to look upLIST — Option store: alist or flat plistReturns: ANY — Stored value, or (thunk) when the key is absent