Groups | Search | Server Info | Login | Register


Groups > comp.lang.lisp > #60457

map-plist

From "B. Pym" <Nobody447095@here-nor-there.org>
Newsgroups comp.lang.lisp, comp.lang.scheme
Subject map-plist
Date 2025-07-02 03:35 +0000
Organization A noiseless patient Spider
Message-ID <10429d7$3acad$1@dont-email.me> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


Pascal Bourguignon wrote:

>  (defun map-plist (fun plist)
>    (loop :for (key value) on plist by #'cddr
>              :collect (funcall fun key value))
> 
...
> 
> Then you can write:
> 
> (map-plist (lambda (k v) (cons k (1+ v))) '(one 1 two 2 three 3))

Gauche Scheme

(use util.match)   ;; match-lambda
(use gauche.lazy)  ;; lslices

(map
  (match-lambda [(k v) (cons k (+ 1 v))])
  (lslices '(one 1 two 2 three 3) 2))

  ===>
((one . 2) (two . 3) (three . 4))

Back to comp.lang.lisp | Previous | NextNext in thread | Find similar


Thread

map-plist "B. Pym" <Nobody447095@here-nor-there.org> - 2025-07-02 03:35 +0000
  Re: map-plist "B. Pym" <Nobody447095@here-nor-there.org> - 2025-08-30 22:39 +0000

csiph-web