lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Axis_group_engraver + Scheme engraver for staff combining (issue 576


From: thomasmorley65
Subject: Re: Axis_group_engraver + Scheme engraver for staff combining (issue 576540043 by address@hidden)
Date: Mon, 18 Mar 2019 15:55:37 -0700

On 2019/03/18 22:26:15, dak wrote:
mailto:address@hidden 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


Aargh, replacing `(lambda (a b) (list a b))´ with `list´ is ofcourse far
better.
I considered to use simple `cdr´ instead of `(lambda (x) (eq? #t (cdr
x)))´, though one would need to ensure the `cdr´ is always a boolean,
otherwise our procedures would return differently sometimes.  Saul said
so, though I thought better be paranoid than sorry ...


https://codereview.appspot.com/576540043/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]