• Re: Newbie Question: How do I mass-populate a hash table?

    From B. Pym@21:1/5 to All on Wed Sep 25 03:26:55 2024
    XPost: comp.lang.scheme

    Populating a hash table using a property list. A property list
    has a form like '(one "ONE" two "TWO" ....).

    (defun populate-hash-table (table property-list)
    (loop for (key value) on property-list by #'cddr
    do (setf (gethash key table) value)))

    Gauche Scheme

    (define (prop-list->alist plist)
    (do ((al '()))
    ((null? plist) al)
    (push! al (cons (pop! plist) (pop! plist)))))

    (prop-list->alist '(foo 33 bar 42 k 99))
    ===>
    ((k . 99) (bar . 42) (foo . 33))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)