Code from Matthew Clegg with some similar goals as my roll_funcs.R stuff
In boolean contexts, change several '&' and '|' to '&&' and '||'.