From 355bbfd898a8b61797b3a077f15c5f97ab7ebb04 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sun, 30 Nov 2025 11:11:09 +0100 Subject: Add contracts related to nutrient-value. --- models/nutrient.rkt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'models/nutrient.rkt') 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?)) -- cgit v1.2.3