5

I don't know what's going wrong with this snippet:

\version "2.24"

multiDynScoresDoc = #(define-void-function
  (filename title staves)
  (string? string? list?)
  (toplevel-book-handler #{
    \book {
      \bookOutputName #filename

      \header {
        title = #title
      }

      $@(map
        (lambda (staff) (#{
          \score {
            $staff
          }
        #}))
        staves
      )
    }
  #})
)

staffA = \new Staff { \time 2/4 a8 a8 a8 a8 }
staffB = \new Staff { \time 2/4 b8 b8 b8 b8 }
staffC = \new Staff { \time 2/4 c8 c8 c8 c8 }

\multiDynScoresDoc #"test" "Test" #(list 
  staffA staffB staffC
)

Lilypond output:

GNU LilyPond 2.24.3 (running Guile 2.2)
Processing `./test.ly'
Parsing...
./test.ly:14:8: error: Guile signaled an error for the expression beginning here
      $
       @(map
Wrong type to apply: #<Score>
./test.ly:30:1: error: error in #{ ... #}

\multiDynScoresDoc #"test" "Test" #(list 
fatal error: failed files: "./test.ly"

1 Answer 1

6

This is just a Scheme error since you are trying to call a score as a function in Scheme.

Instead of (lambda (staff) (#{… you need to write (lambda (staff) #{… and of course also remove the corresponding closing parenthesis.

If you don't, the lambda form does not return a score but rather tries calling the score and return the result from that call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.