diff options
| author | Marius Peter <dev@marius-peter.com> | 2025-11-30 11:11:09 +0100 |
|---|---|---|
| committer | Marius Peter <dev@marius-peter.com> | 2025-11-30 11:11:09 +0100 |
| commit | 355bbfd898a8b61797b3a077f15c5f97ab7ebb04 (patch) | |
| tree | f4d64c5db18d04dec249eb939ede834148a26acc /models/nutrient.rkt | |
| parent | d70e4dc1318d461d4da9fec5b5c1aa73a299f23c (diff) | |
Add contracts related to nutrient-value.
Diffstat (limited to 'models/nutrient.rkt')
| -rw-r--r-- | models/nutrient.rkt | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/models/nutrient.rkt b/models/nutrient.rkt index dd8d677..1103aac 100644 --- a/models/nutrient.rkt +++ b/models/nutrient.rkt @@ -6,6 +6,8 @@ nutrient-canonical-name nutrient-french-name nutrient-formula + nutrient-value? + maybe-nutrient-value? nutrient-value-hash/c (contract-out [create-nutrient! (-> string? string? string? nutrient?)] [get-nutrients (-> (listof nutrient?))] @@ -33,7 +35,9 @@ #:property prop:custom-write (λ (v out _) (fprintf out "#<~a ~a>" (nutrient-id v) (nutrient-canonical-name v)))) -(define nutrient-value-hash/c (hash/c nutrient? (and/c real? (>=/c 0)) #:immutable #t)) +(define nutrient-value? (and/c real? (>=/c 0))) +(define maybe-nutrient-value? (or/c nutrient-value? #f)) +(define nutrient-value-hash/c (hash/c nutrient? nutrient-value? #:immutable #t)) ;; vector/c id, canonical name, french name, nutrient formula, value (ppm) (define residual-vector/c (vector/c exact-nonnegative-integer? string? string? string? real?)) |