next up previous contents
Next: Miscellaneous abstractions Up: Associative Lists in A++ Previous: Abstractions for associative lists   Contents


Application of associative lists


(define keys (cons 'eins  
                    (cons 'zwei  
                           (cons 'drei 
                                  (cons 'vier nil)))))
;
(define values (cons 'one 
                      (cons 'two 
                             (cons 'three 
                                    (cons 'four nil)))))
;
(define dictionary (map2 (lambda(m1 m2)
                           (cons m1 m2))
                         keys
                         values))
;
(aldisp! dictionary)
                            -->eins
                            -->one
                            -->zwei
                            -->two
                            -->drei
                            -->three
                            -->vier
                            -->four
;
(define result (assoc 'drei dictionary))
;
(if (equal false result)
     (bdisp! false)
     (print (cdr result)))
                            -->three
                            void
;
(define result (assoc 'fuenf dictionary))
;
(if (equal false result)
     (bdisp! false)
     (print (cdr result)))
                            -->false
                            void



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz