thomasmorle...@gmail.com writes:

> On 2019/03/17 01:45:49, saul.james.tobin wrote:
>
>> Re cdr is not a predicate — the list being processed here is composed
> of
>> pairs, the cdr of which is ##t or ##f.
>
> The description is still confusing. Do you mean something like below?
>
> #(define (divide-true-cdr ls)
> "Split @var{ls} into those elements which do and don't have a tail of
> value
> @code{#t}"
>  (call-with-values
>    (lambda () (partition (lambda (x) (eq? #t (cdr x))) ls))
>    (lambda (a b) (list a b))))
>
> #(display (divide-true-cdr '((1 . #f) (2 . #t) (3 . #f))))
>
> => (((2 . #t)) ((1 . #f) (3 . #f)))

The silence of the lambdas (almost):

#(define (divide-true-cdr ls)
  "Split @var{ls} into those elements which don't and do have a tail of
  value @code{#tf}"
  (call-with-values (lambda () (partition cdr ls)) list))

#(display (divide-true-cdr '((1 . #f) (2 . #t) (3 . #f))))
=> (((2 . #t)) ((1 . #f) (3 . #f)))

-- 
David Kastrup

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to