aboutsummaryrefslogtreecommitdiff
path: root/src/Food.purs
diff options
context:
space:
mode:
authorJoris2017-04-05 17:04:33 +0200
committerJoris2017-04-05 17:04:33 +0200
commit9a95a674fbbf1e64d3ad07922d569c3a1c751cf2 (patch)
tree2f99889040b0af406df1c403b9d930fe77e706cf /src/Food.purs
parentf6a73e5bd6a5e2d7d4eb9c8a14bdf1a0c8a4ac4c (diff)
Show aliments, glycemic index, carbohydrates and glycemic charge
Diffstat (limited to 'src/Food.purs')
-rw-r--r--src/Food.purs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Food.purs b/src/Food.purs
new file mode 100644
index 0000000..b1e3d29
--- /dev/null
+++ b/src/Food.purs
@@ -0,0 +1,25 @@
+module Food
+ ( Aliment
+ , all
+ , glycemicLoad
+ ) where
+
+import Data.Int (toNumber)
+import Prelude
+
+type Aliment =
+ { name :: String
+ , glycemicIndex :: Int
+ , carbohydrates :: Int -- for 100 grams
+ }
+
+glycemicLoad :: Aliment -> Number
+glycemicLoad aliment = toNumber aliment.glycemicIndex * toNumber aliment.carbohydrates / 100.0
+
+all :: Array Aliment
+all =
+ [ { name: "oignon", glycemicIndex: 15, carbohydrates: 9 }
+ , { name: "olive", glycemicIndex: 15, carbohydrates: 6 }
+ , { name: "haricot rouge", glycemicIndex: 35, carbohydrates: 24 }
+ , { name: "haricot blanc", glycemicIndex: 35, carbohydrates: 13 }
+ ]