Thomas Morley <thomasmorle...@googlemail.com> writes:

> Seems I have to extend my scheme-vocabulary.
> I didn't know/remember `append-map' and `string-concatenate'.

Picked them from the Guile manuals.

> I really have to learn more of the predefined guile-procedures.
>
>>>          (new-args (list-join args-rev " "))
>>
>> list-join?
>
> I wanted to insert " " between every element of new-args. Otherwise
> there will be no space between the words of  p.e. \markup \char-space
> #1 { This little text }
> list-join seems to be a nice function to do so. Anything problematic
> with it?

I did not find it in the Guile documentation and did not think of
looking in scm/lily-library.scm instead.  Looks suboptimal: an
unnecessary test inside of the loop.

Better is likely

(define-public (list-join lst intermediate)
  (if (null? lst) lst
      (cons (car lst)
            (append-map!
               (lambda (elem) (list intermediate elem))
               (cdr lst)))))

Or even

(define-public (list-join lst intermediate)
  (if (null? lst) lst
      (cons (car lst)
            (concatenate!
              (zip (circular-list intermediate) (cdr lst))))))

The last version is probably fastest since it avoids any user-defined
function in the loop.

>>>  (ly:stencil-combine-at-edge
>>>    (ly:stencil-combine-at-edge
>>>       (ly:make-stencil ""
>>>              (cons 0 (abs (* pos-nmbr 3 (if (number? word-space-left)
>>>    word-space-left word-space))))
>>
>> word-space-left has been given a default in the function definition.  So
>> if it is not a number, this is an error case I would not try to catch.
>
> Do you mean writing
>
>  (ly:stencil-combine-at-edge
>    (ly:stencil-combine-at-edge
>       (ly:make-stencil ""
>              (cons 0 (abs (* pos-nmbr 3 (if word-space-left
> word-space-left word-space))))
>
> instead?

No.

(ly:stencil-combine-at-edge
  (ly:stencil-combine-at-edge
     (ly:make-stencil ""
            (cons 0 (abs (* pos-nmbr 3 word-space-left))))))

word-space-left has no business being anything but a number.

-- 
David Kastrup

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

Reply via email to