[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optional arguments for scheme functions
From: |
Thomas Morley |
Subject: |
Re: Optional arguments for scheme functions |
Date: |
Sun, 26 Apr 2020 10:30:58 +0200 |
Am So., 26. Apr. 2020 um 02:35 Uhr schrieb Fr. Samuel Springuel
<address@hidden>:
>
> I’m trying to write a music function in scheme in which the first argument is
> optional and have run into something that confuses me:
>
> The following works:
>
> \version "2.19.84"
>
> recite = #(define-music-function (times note) ((integer? 1) ly:music?)
> #{ \repeat unfold #times { #note }
> #})
>
> \new Staff {
> \new Voice { g' \recite g' g' }
> }
>
> However, when I swap integer? for positive? (to reflect the fact that only a
> positive integer should be acceptable) it breaks, telling me the argument at
> position 1 is of the wrong type (it’s music, not a positive number). Why
> doesn’t scheme’s handling of optional arguments work when using the positive?
> predicate?
>
I've no clue why positive? fails here.
Though, for integers >= 0 we have the index? predicate, which works in
your function.
Cheers,
Harm