[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Defining new Scheme predicates
From: |
David Kastrup |
Subject: |
Re: Defining new Scheme predicates |
Date: |
Mon, 07 Nov 2016 11:11:31 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
> Am 7. November 2016 01:20:23 MEZ, schrieb Andrew Bernard
> <address@hidden>:
>>Hi Simon,
>>
>>Thanks! Exactly perfect. Sometimes the completely obvious escapes me.
>>Better
>>have another coffee.
>>
>>Most appreciated.
>>
>>I suppose of course that to make it a predicate without the preliminary
>>let
>>block (not that I have any objection to that) one would have to modify
>>lilypond internals, which would not be desirable.
>
> Not at all!
>
> Just define your predicate with
>
> #(define (side? obj)
> (if (or (eq? obj 'left)
> (eq? obj 'right))
> #t #f))
When I see something like (if ... #t #f) I get a rash. It doesn't
really get more redundant than that.
At any rate, the usual check would be (memq obj '(left right)) and if
you really need #t when true (rather than anything but #f) you can still
write (and (memq obj '(left right)) #t). But if you work with eq? like
you did, the results will be #f and #t anyway already.
As a condition, anything but #f counts as true.
--
David Kastrup
- Defining new Scheme predicates, Andrew Bernard, 2016/11/06
- Re: Defining new Scheme predicates, Simon Albrecht, 2016/11/06
- Re: Defining new Scheme predicates, Simon Albrecht, 2016/11/06
- RE: Defining new Scheme predicates, Andrew Bernard, 2016/11/06
- Re: Defining new Scheme predicates, Thomas Morley, 2016/11/06
- RE: Defining new Scheme predicates, Urs Liska, 2016/11/07
- Re: Defining new Scheme predicates, Richard Shann, 2016/11/07
- Re: Defining new Scheme predicates, Urs Liska, 2016/11/07
- Re: Defining new Scheme predicates, Urs Liska, 2016/11/07
- Re: Defining new Scheme predicates, David Kastrup, 2016/11/07
- Re: Defining new Scheme predicates,
David Kastrup <=