<RefEntry id="assoc"> <!-- This file is generated automatically from the DSSSL source. --> <!-- Do not edit this file! --> <?html-filename assoc.html> <RefMeta> <RefEntryTitle>assoc</RefEntryTitle> <RefMiscInfo Role="file">dblib.dsl</RefMiscInfo> </RefMeta> <RefNameDiv> <RefName>assoc</RefName> <RefPurpose>Returns the association of an object in an associative list</RefPurpose> </RefNameDiv> <RefSynopsisDiv><Title>Synopsis</Title> <Synopsis> (assoc obj alist) </Synopsis> </RefSynopsisDiv> <RefSect1><Title>Description</Title> <para> Given an associative list, returns the pair that has <literal>obj</literal> as a <literal>car</literal> or <literal>#f</literal> if no such pair exists. </para> <variablelist> <varlistentry><term>obj</term> <listitem> <para> The associative key to locate. </para> </listitem> </varlistentry> <varlistentry><term>alist</term> <listitem> <para> The associative list. </para> </listitem> </varlistentry> </variablelist> </RefSect1> <RefSect1><Title>Example</Title> <para> <literal>(assoc "a" (("a" "b") ("c" "d")))</literal> returns <literal>("a" "b")</literal> </para> </RefSect1> <RefSect1><Title>Author</Title> <para> Norman Walsh, <ndw@nwalsh.com> </para> </RefSect1> <RefSect1><Title>Source Code</Title> <ProgramListing> (define (assoc obj alist) ;; Returns the association of an object in an associative list (let loop ((al alist)) (if (null? al) #f (if (equal? obj (car (car al))) (car al) (loop (cdr al)))))) </ProgramListing> </RefSect1> </RefEntry>