# Gauging Interest:RFC to add map() function

- Thread: https://externals.io/message/67889
- Original archive: https://news-web.php.net/php.internals/67889
- Started by Jeremy Curcio on 2013-06-26T16:09:40+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #67889 — Jeremy Curcio — 2013-06-26T16:09:40+00:00

URL: https://externals.io/message/67889#67889

>I am curious with something that is so easy; why would you want it in core?

A lot of the Math Functions could be considered "so easy".
 `abs()` could be written out as:
    function abs($n) {
        if ($n >= 0) return $n;
        else return $n*-1;
    }
 `pi()` could be replaced by simply setting a global variable equal to 3.14159265358979
 `floor()` could be written out as:
    function floor($n) {
        $stop = strpos($n, '.');
        if ($stop !== false) return substr($n,0,$stop);
        else return $n
    }
 `ceil()` could be written out as:
    function ceila($n) {
        $stop = strpos($n, '.');
        if ($stop !== false) return 1+substr($n,0,$stop);
        else return $n;
    }

The above examples are just a few that stick out to me I'm sure that looking through the list of available math functions would provide a few more examples. Keeping these examples in mind, I don't follow the logic of range mapping being too easy to implement manually whenever it is needed to not warrant being included in core.

---

## #67890 — johannes@schlueters.de — 2013-06-26T16:17:02+00:00

URL: https://externals.io/message/67889#67890 · In reply to: #67889

> 
> The above examples are just a few that stick out to me I'm sure that
> looking through the list of available math functions would provide a
> few more examples. Keeping these examples in mind, I don't follow the
> logic of range mapping being too easy to implement manually whenever
> it is needed to not warrant being included in core. 

The mentioned functions are very very very common math functions. Your
map() is relatively specialized.

johannes
