[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: where to put useful lists in the docs?
From: |
Mark Polesky |
Subject: |
Re: where to put useful lists in the docs? |
Date: |
Wed, 27 May 2009 02:32:13 -0700 (PDT) |
Mark Polesky wrote:
> I've updated ly:sort-alist to cope with non-numeric values.
> Here they are again:
oops. the last ly:sort-alist won't work. This one will.
(define (ly:sort-alist alist prop)
#! Return a sorted list of pairs (entry . prop-value) of "alist"
entries that have "prop" as a key. !#
(let ((value (lambda (a) (ly:assoc-get prop (cdr a)))))
(sort-list (map (lambda (a) (cons (car a) (value a)))
(filter value alist))
(lambda (a b)
(if (number? (cdr a))
(< (cdr a) (cdr b))
(string<? (symbol->string (cdr a))
(symbol->string (cdr b))))))))
(define (ly:filter-alist alist prop . value)
#! Return a list of "alist" entries that have "prop" as a key (if
"value" is unspecified), or that have "prop" set to "value" (if
specified), or that do *not* have "prop" as a key (if "value" is
'unset). !#
(map car
(filter
(lambda (entry)
(let ((this-value (ly:assoc-get prop (cdr entry) 'unset)))
(if (null? value)
(not (eq? this-value 'unset)) ; value is set.
(eq? (car value) this-value)))) ; value is a match.
alist)))
test flexible sorting:
;(display (ly:sort-alist all-grob-descriptions 'outside-staff-priority))
;(display (ly:sort-alist all-grob-descriptions 'break-align-symbol))
- where to put useful lists in the docs?, Mark Polesky, 2009/05/25
- Re: where to put useful lists in the docs?, Mark Polesky, 2009/05/25
- Re: where to put useful lists in the docs?, Neil Puttock, 2009/05/28
- Re: where to put useful lists in the docs?, Mark Polesky, 2009/05/29
- [PATCH] Re: where to put useful lists in the docs?, Mark Polesky, 2009/05/29
- Re: [PATCH] Re: where to put useful lists in the docs?, Mark Polesky, 2009/05/30
- Re: [PATCH] Re: where to put useful lists in the docs?, Nicolas Sceaux, 2009/05/30
- Re: [PATCH] Re: where to put useful lists in the docs?, Werner LEMBERG, 2009/05/30
- Re: [PATCH] Re: where to put useful lists in the docs?, Mark Polesky, 2009/05/30
- Re: [PATCH] Re: where to put useful lists in the docs?, Mark Polesky, 2009/05/30
- Re: where to put useful lists in the docs?, Graham Percival, 2009/05/30