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

Liste des GroupesRevenir à cl scheme 
Sujet : Re: Newbie Question: How do I mass-populate a hash table?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.scheme
Date : 25. Sep 2024, 04:26:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vcvvtu$3i202$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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))

Date Sujet#  Auteur
25 Sep 24 o Re: Newbie Question: How do I mass-populate a hash table?1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal