[Racket] Ferti hydroponic nutrient solver, redux.
Add nutrient-value-pair/c contract.
models/nutrient.rkt
@@ -1,12 +1,14 @@
1
1
#lang racket
2
2
3
3
(provide
4
Removed:
;; Struct definitions
4
Added:
;; Model struct
5
5
nutrient
6
6
nutrient?
7
7
nutrient-id nutrient-name nutrient-formula
8
Removed:
;; SQL CRUD
8
Added:
;; Contracts
9
Added:
nutrient-value-pair/c
9
10
(contract-out
11
Added:
;; SQL CRUD
10
12
[create-nutrient! (-> string? string? nutrient?)]
11
13
[get-nutrients (-> (listof nutrient?))]
12
14
[get-nutrient (->* ()
@@ -32,6 +34,9 @@
32
34
(fprintf out "#<~a ~a>"
33
35
(nutrient-id v)
34
36
(nutrient-name v))))
37
Added:
38
Added:
(define nutrient-value-pair/c
39
Added:
(cons/c nutrient? (and/c real? (>=/c 0))))
35
40
36
41
37
42
;; CREATE