Aaron: I just had a chance to go over this. Your details helped all makes sense to me, Thank you for your time, greatly appreciated. ƒg
On Fri, May 8, 2020 at 1:44 AM Aaron Hill <lilyp...@hillvisions.com> wrote: > > On 2020-05-07 9:42 pm, Freeman Gilmore wrote: > > On Thu, May 7, 2020 at 11:32 PM Aaron Hill <lilyp...@hillvisions.com> > > wrote: > >> %%%% > >> \version "2.20.0" > >> > >> sum = > >> #(define-void-function > >> (args) > >> (number-list?) > > I know the the function uses a list for this because of the > > undetermined number of args as the lambda procedure did. In > > (number-list?) how do you know what goes here, say it is not a number, > > like a list of similes? > > You put whatever type predicate makes sense for the function. The > Notation Reference lists all of the predefined ones, whether they are > primitives specified by R5RS (the Scheme standard that Guile follows) or > defined by LilyPond itself. > > But you can also define your own type predicates: > > %%%% > \version "2.20.0" > > #(define (flavor? x) > (member x '(vanilla chocolate strawberry))) > > cake = > #(define-void-function > (flavor) (flavor?) > (format #t "\n~a cake is delicious!" flavor)) > > \cake chocolate > > #(define (flavor-list? x) > (and (list? x) > (every flavor? x))) > > layeredCake = > #(define-void-function > (flavors) (flavor-list?) > (format #t "\n~{~a~^ and ~} cake is delicious!" flavors)) > > \layeredCake vanilla, strawberry > %%%% > > ==== > GNU LilyPond 2.20.0 > Processing `type-predicate.ly' > Parsing... > chocolate cake is delicious! > vanilla and strawberry cake is delicious! > Success: compilation successfully completed > ==== > > > >> (format #t "\nargs: ~s, sum: ~s" args (apply + args))) > > I do not have a clue what this all means "(format #t "\nargs: ~s, sum: > > ~s" args" Where can i find this information? > > See the documentation on Formatted Output [1]. I have shared a PDF > version of the Guile 1.8 docs here [2] that makes a handy companion to > the LilyPond docs for offline use. Also included is the R5RS reference. > > [1]: > https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Formatted-Output.html#Formatted-Output > [2]: https://drive.google.com/open?id=1WQ6zhMRUxf6-zdw3Gcv0SuuUI311Bu90 > > > >> \sum 2, 3, 5 > > Tried this and {a \sum2,3,5 b} (note spacing) and it worked, which is > > what i was looking for. But {a \sum 2, -3, 5 b} does not work? How > > to fix this so it does? > > Technically, when one says something like "2,3,5" in LilyPond, that is a > key-list? as far as the parser's logic is concerned. A "key" in this > context refers to either an index (non-negative integer) or a symbol. > > To support general numbers, you will need to use Scheme syntax: > > %%%% > \sum #'(1 -2/3 4.5) > %%%% > ==== > args: (1 -2/3 4.5), sum: 4.83333333333333 > ==== > > > -- Aaron Hill