[Top][All Lists]

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

Re: utf-8-strings

From: David Kastrup
Subject: Re: utf-8-strings
Date: Sun, 08 Jul 2012 17:32:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Thomas Morley <address@hidden> 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)
               (lambda (elem) (list intermediate elem))
               (cdr lst)))))

Or even

(define-public (list-join lst intermediate)
  (if (null? lst) lst
      (cons (car lst)
              (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?


     (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

reply via email to

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