【问题标题】:how to make contract for a non-empty hashtable如何为非空哈希表创建合约
【发布时间】:2017-06-13 18:22:45
【问题描述】:

Racket 有一个non-empty-listof 合约,但没有non-empty-hashof 合约。有没有办法建立一个?

【问题讨论】:

标签: racket contract


【解决方案1】:

谓词可以用作契约,所以:

(define (non-empty-hash? x)
  (and (hash? x)
       (not (hash-empty? x))))

那么你可以使用non-empty-hash?作为你的合约。

【讨论】:

    猜你喜欢
    • 2012-01-02
    • 1970-01-01
    • 2013-04-25
    • 2011-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-20
    • 2010-09-06
    相关资源
    最近更新 更多