I'd argue that this bit of mathematical logic carries over to many programming languages. For example using LINQ expressions in C#:
https://dotnetfiddle.net/3QGurc