Created
February 15, 2013 15:50
-
-
Save joaodubas/4961234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tbl = { | |
{ | |
name='Very severely underweight', | |
upper=15 | |
}, | |
{ | |
name='Severely underweight', | |
lower=15, | |
upper=16 | |
}, | |
{ | |
name='Underweight', | |
lower=16, | |
upper=18.5 | |
}, | |
{ | |
name='Normal', | |
lower=18.5, | |
upper=25 | |
}, | |
{ | |
name='Overweight', | |
lower=25, | |
upper=30 | |
}, | |
{ | |
name='Moderately obese', | |
lower=30, | |
upper=35 | |
}, | |
{ | |
name='Severely obese', | |
lower=35, | |
upper=40 | |
}, | |
{ | |
name='Very severely obese', | |
lower=40 | |
} | |
} | |
bmi = 93.7 / 1.68 ^ 2 | |
bmi_classification = '' | |
for index, classification in ipairs(tbl) do | |
lower = true | |
upper = true | |
if classification['lower'] then | |
lower = bmi >= classification['lower'] | |
end | |
if classification['upper'] then | |
upper = bmi < classification['upper'] | |
end | |
if lower and upper then | |
bmi_classification = classification.name | |
bmi_lower = 'lower ' .. (classification['lower'] or '') | |
bmi_upper = 'upper ' .. (classification['upper'] or '') | |
break | |
end | |
end | |
print(bmi, bmi_classification, bmi_lower, bmi_upper) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment