Sujet : re: lisp newbie here
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 14. Jul 2024, 11:41:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v706gv$3a5o$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Alex Mizrahi wrote:
in kmrcl package you can find such implementations:
(defun alist-plist (alist)
(apply #'append (mapcar #'(lambda (x) (list (car x) (cdr x))) alist)))
Did you see the idiocy?
#'(lambda
Lambda is a macro that expands to (function (lambda ...)).
Users of CL are extremely eager to produce the
ugliest code possible.
Gauche Scheme
(define (alist->plist alist)
(append-map
list
(map car alist)
(map cdr alist)))
Another way:
(use util.match)
(define (alist->plist alist)
(match alist
[((k . v) ...)
(append-map list k v)]))