shithub: touchuichal

ref: 8f0e673b7d5677a1b29a4fdd045c7a88d2008994
dir: /calc.awk/

View raw version
#!/bin/awk -f

# meant to be executed within acme with records that look like this:

# 5 * 3
# 2 * 1

{
	num1 = $1
	num2 = $3
	fac = num1 * num2 * 0.1
	
	sum += fac
	pure += num1
	
	if (num2 > 5) {
		pexp += num1
		nexp++
	} else {
		pun += num1
		nun++
	}
	count++
	printf "%s\n", $0
}

END {
	printf "%.2f / %d = %f (weighted)\n", sum, count, sum/count
	printf "%.2f / %d = %f\n", pure, count, pure/count
	printf "experienced:   %d → %f\n", nexp, pexp/nexp
	printf "unexperienced: %d → %f\n", nun, pun/nun
}