[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] What use, if any, is `any?' ?
From: |
Mario Domenech Goulart |
Subject: |
Re: [Chicken-users] What use, if any, is `any?' ? |
Date: |
Wed, 05 Aug 2015 15:00:28 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Hi Nick,
On Wed, 05 Aug 2015 10:11:15 -0400 Nick Andryshak <address@hidden> wrote:
> I came across this function in the official documentation recently:
>
> http://wiki.call-cc.org/man/4/Unit%20data-structures#any
>
>>any?
>>[procedure] (any? X)
>>Ignores its argument and always returns #t. This is actually useful
>>sometimes.
>
> Is it, though? Does anyone have any practical examples? And why couldn't
> you just replace any usages of (any? x) with just plain #t?
Combinators are usually useful when used as arguments to procedures.
Not really a practical example, but just to illustrate a case with any?:
(define (foo proc)
(proc 42))
(print (foo negative?))
(print (foo any?))
You can't really use (foo #t), since foo expects a procedure as
argument. You may argue that you could simply use (print #t), but then
you don't need a combinator in the first place. :-)
Best wishes.
Mario
--
http://parenteses.org/mario