lilypond-user
[Top][All Lists]
Advanced

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

Re: Attaching an alist to a grob


From: Richard Shann
Subject: Re: Attaching an alist to a grob
Date: Wed, 14 Jan 2015 11:41:50 +0000

On Wed, 2015-01-14 at 12:34 +0100, Urs Liska wrote:
> Am 14.01.2015 um 12:28 schrieb Richard Shann:
> > On Wed, 2015-01-14 at 11:29 +0100, Urs Liska wrote:
> >> Am 14.01.2015 um 11:18 schrieb Mattes:
> >>>    
> >>> Am Mittwoch, 14. Januar 2015 09:42 CET, Urs Liska <address@hidden> 
> >>> schrieb:
> >>>    
> >>>> Yes, I made some surprising progress with Scheme recently. I didn't even
> >>>> get stuck in the ands and parens in the actual predicate I wrote
> >>>>
> >>>> #(define (annotation? obj)
> >>>>       (and
> >>>>        (and (list? obj)
> >>>>             (every pair? obj))
> >>>>        (and (if (assoc-ref obj "type") #t #f)
> >>>>             (if (assoc-ref obj "location") #t #f))))
> >>> Proper indentation helps ;-)
> >>> But why so contrived? Your code is equivalent to:
> >>>
> >>> #(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.

yes, and in Scheme all expressions except #f are true. (That's why #t is
used so rarely, because it is just an "empty" symbol, used when you
haven't got anything else.)

Richard



> 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.
> 
> Urs
> 
> >
> > Richard
> >
> >
> >
> >>> HTH Ralf Mattes
> >>>    
> >>>    
> >>>
> >> Thanks, this is of course better.
> >> sorting out nested conditionals has never been my strongest point ;-)
> >>
> >> Urs
> >>
> >> _______________________________________________
> >> lilypond-user mailing list
> >> address@hidden
> >> https://lists.gnu.org/mailman/listinfo/lilypond-user
> >
> 





reply via email to

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