Script: implement min and max expressions