[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scheme-question about accumulating lists of lists
From: |
David Pirotte |
Subject: |
Re: scheme-question about accumulating lists of lists |
Date: |
Mon, 22 Apr 2019 23:12:03 -0300 |
Hello THomas,
> ...
> Now `core-guile-condition´ feels like a case for `match´, but I
> couldn't make it work.
> Is this a bad use case and alist searching is always preferable?
I would do this:
(define (is-spanner? grob)
(match grob
((g-key . g-vals)
(let ((meta (assq-ref g-vals 'meta)))
(and meta
(eq? (assq-ref meta 'class)
'Spanner)
g-key)))))
Which you could generalize:
(define (lp-grob-is-a? grob class)
(match grob
((g-key . g-vals)
(let ((meta (assq-ref g-vals 'meta)))
(and meta
(eq? (assq-ref meta 'class)
class)
g-key)))))
Then filtering becomes:
(define grobs
'((Name-1 . ((foo . x)
(bar . y)
(buzz . z)
(meta . ((name . Name-1)
(class . Spanner)
(ifaces . (i1 i2 i3))))))
(Name-2 . ((foo . m)
(bar . n)
(buzz . o)
(meta . ((name . Name-2)
(class . Not-a-Spanner)
(ifaces . (i4 i5 i6))))))
(Name-3 . ((foo . m)
(bar . n)
(buzz . o)
(meta . ((name . Name-3)
(class . Spanner)
(ifaces . (i7 i8 i9))))))))
scheme@(guile-user)> (filter-map
(lambda (grob)
(lp-grob-is-a? grob 'Spanner))
grobs)
$6 = (Name-1 Name-3)
> As a side note.
> I'd like to download the "Guile Reference Manual" as one big-page
> .html, but couldn't find any for 2.9.1.
> Not yet done?
No, but you could locally build it, using the glib gendoc.sh script, let me
know if
you need help with this, I can cook sometig for you ...
David.
pgpU6sLj2NF4C.pgp
Description: OpenPGP digital signature
- Re: scheme-question about accumulating lists of lists, (continued)
- Re: scheme-question about accumulating lists of lists, Malte Meyn, 2019/04/19
- Re: scheme-question about accumulating lists of lists, Thomas Morley, 2019/04/19
- Re: scheme-question about accumulating lists of lists, David Pirotte, 2019/04/19
- Re: scheme-question about accumulating lists of lists, David Pirotte, 2019/04/19
- Re: scheme-question about accumulating lists of lists, David Pirotte, 2019/04/19
- Re: scheme-question about accumulating lists of lists, Thomas Morley, 2019/04/20
- Re: scheme-question about accumulating lists of lists, David Pirotte, 2019/04/20
- Re: scheme-question about accumulating lists of lists, Thomas Morley, 2019/04/21
- Re: scheme-question about accumulating lists of lists, David Pirotte, 2019/04/21
- Re: scheme-question about accumulating lists of lists, Thomas Morley, 2019/04/22
- Re: scheme-question about accumulating lists of lists,
David Pirotte <=
- Re: scheme-question about accumulating lists of lists, Thomas Morley, 2019/04/23