Nicolas Sceaux wrote:
> This is not the way to do it in guile scheme. When you find 
> yourself using primitive-eval, ask yourself if there is not a
> better way. To write code that writes codes, use macros: read
> about defmacro. Also note that you usually don't use underscores
> in function names.

Well, I did ask myself if there was a better way, and I answered,
"not that I'm aware". I've always been plagued by the notion that
my scheme code is needlessly bloated, but sometimes I can't read
between the concise lines of R5RS or the guile reference manual.
Occasionally my only sensible option is to publicly share bloated
code, and hope that someone like you points me in the right
direction. Thanks!

About the underscores: yes, I gathered that underscores were
avoided, but I simply thought pairgcd looked dumb.

> But in that particular case, why not define a function that
> takes a function and a list of pairs? It's usual to have
> procedure arguments:
>
> (define (map-on-pairs fn pairs)
>   (cons (apply fn (map car pairs))
>         (apply fn (map cdr pairs))))
>
> (map-on-pairs + '((1 . 1) (2 . 3) (5 . 8))) => (8 . 12)
> (map-on-pairs min '((1 . 8) (1 . 5) (2 . 3))) ==> (1 . 3)

Well, I wanted variadic functions just like + and the rest. But
now it's a trivial matter; if I want the above functionality, I
can just do:

(define (pair+ . pairs)
  (map-on-pairs + (values pairs)))

etc.

Thanks.
- Mark


      


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

Reply via email to