[racket] (procedure? (hash)) -> true

From: John Griffin (jg at ittalentteam.com)
Date: Tue Aug 6 06:17:12 EDT 2013

Thanks Matthias for the #%app idea.   This appears to work exactly as I had wanted such that a hash in function position works with one arg.   In the rare case where my application does not want the default #f, I'll just use (hash-ref) in the normal fashions.

(module my-racket racket
  (provide (rename-out [my-app #%app]))
  
  (define-syntax my-app
    (syntax-rules ()
      [(_ f) (f)]
      [(_ f k)
       (let ((F f))
         (if (hash? F)
             (#%app hash-ref F k #f)
             (#%app F k)))]
      [(_ f e ...)
       (#%app f e ...)])))

Posted on the users mailing list.