2017-08-26

(sph alist)

association list processing

part of sph-lib

example

(alist-q a 1 b 2)

import name

(sph alist)

exports

alist

procedure

signature

key/value ... ->

key/value ... -> alist

description

create an association list from the given arguments,

mapping each argument alternatingly to key and value.

(alist (quote a) 1 "b" 2 (quote c) 3)

alist-bind

syntax

signature

alist (key ...) body ...

alist-bind-and*

syntax

signature

alist (key ...) body ...

alist-cond

procedure

signature

a alist ->

any ((procedure:{any -> any/false} alist-tail ...) ...) -> alist-tail/false

description

like a cond expression but with an alist for the test conditions where the tail of the alist is returned for which the test suceeds.

alist-contains

procedure

signature

a key ->

alist-containsq

procedure

signature

a key ->

alist-containsv

procedure

signature

a key ->

alist-delete

procedure

signature

key alist [k=] ->

alist-delete-multiple

procedure

signature

a keys ... ->

alist-keys

syntax

signature

alist

alist-keys-map

procedure

signature

proc a ->

alist-map

procedure

signature

proc a ->

procedure:{key value -> any} list -> list

alist-merge

procedure

signature

a b ->

list list -> list

description

create a new alist with the associations of both alists, preferring entries of "b"

alist-prepend

procedure

signature

a b c ->

alist-q

syntax

signature

key/value ...

alist-ref

syntax

signature

a k d

alist-ref-q

syntax

signature

a k d

alist-select

procedure

signature

alist keys ->

list list -> list

alist-select-apply

procedure

signature

a keys proc ->

description

list list procedure:{any:key-value ...} -> any

applies proc with all alist values for keys in order

alist-select-q

syntax

signature

a (key ...)

alist-select-q-apply

syntax

signature

a (key ...) proc

alist-set

procedure

signature

a key value ->

list any any -> list

description

add or update an entry in an association list

alist-set!

procedure

signature

a b c ->

alist-set-multiple

procedure

signature

a key/value ... ->

description

list [any:key any:value] ...

update or add values in alist for specific keys.

key and value are specified alternatingly

alist-set-multiple-q

syntax

signature

a key/value ...

alist-update

procedure

signature

a b ->

list list -> list

description

update existing entries of a with cWARNING: (sph base): `alist-delete' imported from both (srfi srfi-1) and (sph alist)

orresponding entries of b

alist-update-multiple

procedure

signature

a key/value ... ->

description

list [any:key any:value] ...

update values in alist for specific keys.

key and value are specified alternatingly

alist-update-multiple-q

syntax

signature

a key/value ...

alist-values

syntax

signature

alist

alist?

procedure

signature

a ->

any -> boolean

alistq-ref

procedure

signature

a b ->

alistq-select

procedure

signature

alist keys ->

alists-ref

syntax

signature

a k

alists-ref-p

procedure

signature

a keys ->

description

like alists-ref but as a procedure that accepts a list for keys

alists-ref-q

syntax

signature

a k

alists-set!

syntax

signature

a k v

alistv-ref

procedure

signature

a b ->

alistv-select

procedure

signature

alist keys ->

bindings->alist

syntax

signature

identifier ...

keyword-list->alist+keyless

procedure

signature

a ->

list -> (list:alist any ...)

description

parses a list with arguments similar to lambda* arguments. it creates alist entries for keywords (#: notation, #:example) and subsequently following values (#:example 3 other ...).

if no value follows: (#:example . #t).

all values that do not directly follow a keyword are collected in the tail of the result

list->alist

procedure

signature

lis ->

-> alist

description

create an association list from the given arguments,

mapping each list element alternating to a key and value.

list->group-alist

procedure

signature

lis [accessor] ->

description

group elements in list by an attribute of its elements.

this is the equality of (accessor list-element) between elements and stored under (accessor list-element) as keys.

example

(list->group-alist (1 2 2 3) identity) -> ((1 . (1)) (2 . (2 2)) (3 . (3)))

(list->group-alist ((1 3) (2 5) (2 6)) first) -> ((1 . 3) (2 . (5 6)))

list-alist?

procedure

signature

a ->

list -> boolean

description

return #t if list is an association list, #f otherwise. works only on lists

set-alist-bindings!

procedure

signature

alist ->

description

for each alist part, set a variable named like alist-part-key to alist-part-value

sph-alist-description

variable

tags: programming guile documentation library scheme sph-lib alist sph-alist