Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* Create an operation which will behave as the following
* set of functions (without using "if" statements):
*
* f(x) = 0, for x < 0;
* f(x) = x, for x >= 0 and x < 1;
* f(x) = 1, for x >= 1 and x < 2;
* f(x) = -x + 3, for x >=2 and x < 3;