#!/bin/sh
# usage: selmin < data | min2tex config

exec nawk -v config=$1 '
function end_ex() {
	if( base_data != "" ) {
		printf("\\\\\n");
		base_data = "";
	}
}
BEGIN	{
	base_data = "";
}
$1 == "example" {
	end_ex();
	printf("%s & %s", config, $2);
	config = "";
}
$1 == "data" {
	if( base_data == "" ) {
		base_data = $2;
		printf(" & %.2f", $2);
	} else {
		printf(" & %.2f & %.2f", $2, 100.0*($2/base_data)-100.0);
	}
}
END	{
	end_ex();
}
'
