aboutsummaryrefslogtreecommitdiff
path: root/bmr
blob: 98cbcd9b0b3a3d45469cd995a3dc1dd8dd08c75b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/rc
#
# BMR following the Mifflin-St. Jeor equation
# 	P(kcal/day) = 10*weight(kg) + 6.25*height(cm) - 5*age(yr) + s
# where s is +5 for men and -161 for women
#
rfork ne
s=5
w=()
h=()
a=()
flagfmt='w'
args='weight height age'

fn usage {
	aux/usage
	exit usage
}

if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 3)
	usage

w=$1
h=$2
a=$3

if(~ $flagw 1)
	s=-161

bc <<EOF
scale=4
10*$w + 6.25*$h - 5*$a + $s
EOF