Am 14.01.2015 um 12:42 schrieb Mattes:
Am Mittwoch, 14. Januar 2015 12:34 CET, Urs Liska <u...@openlilylib.org> 
schrieb:

#(define (annotation? obj)
      (and
       (list? obj)
       (every pair? obj)
       (if (assoc-ref obj "type") #t #f)
       (if (assoc-ref obj "location") #t #f)))
...  and is this just equivalent to:

#(define (annotation? obj)
       (and
        (list? obj)
        (every pair? obj)
        (assoc-ref obj "type")
        (assoc-ref obj "location")))


???
I don't think so because the result of the function would be the result
of the last expression.
assoc-ref returns the "value" to the "key", so if passed a valid object
the result of the predicate wouldn't be #t but the content of "location".
That's why I enclosed these checks in if constructs.
Richard is right, the if-clauses aren't neccessary. Scheme has the
concept "generalized" booleans, i.e. anything that isn't explicitly
false is considered to be true:

  guile> (if 42 'true 'false)

I was just trying to keep as much of your code as possible ....

  Cheers, RalfD


OK, I see.
But somehow it feels wrong that

#(display annotation? some-obj)

doesn't produce #t but the content of "location".
Should I ignore that feeling?

Urs


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

Reply via email to