Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #411: Traffic jam on the Information Superhighway.


comp / comp.lang.scheme / Re: Newbie Question: How do I mass-populate a hash table?

SubjectAuthor
o Re: Newbie Question: How do I mass-populate a hash table?B. Pym

1
Subject: Re: Newbie Question: How do I mass-populate a hash table?
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Wed, 25 Sep 2024 03:26 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Newbie Question: How do I mass-populate a hash table?
Date: Wed, 25 Sep 2024 03:26:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <vcvvtu$3i202$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Wed, 25 Sep 2024 05:26:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="eadfc29fe2ac8b34980d94b540501600";
logging-data="3737602"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180wM7pS4jnadTo5rzShW8I"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:oW4O8pGiIFxwem+m9i7Mxxn9huU=
View all headers

> 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))

1

rocksolid light 0.9.8
clearnet tor