Hi Nick,

On Wed, 05 Aug 2015 10:11:15 -0400 Nick Andryshak <nandrys...@gmail.com> 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

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to