## digitalmars.D - What determines if an algorithm goes in std.algorithm or std.range

• aliak (12/12) Jul 14 2018 Alo, I'm wondering how phobos devs view or determine what goes in
• Andrei Alexandrescu (10/25) Jul 16 2018 There is no hard and fast rule. If it does something one would naturally...
aliak <something something.com> writes:
```Alo, I'm wondering how phobos devs view or determine what goes in
to std.algorithm and what goes in to std.range.

To me some of them are quite obvious - well, most things can
arguably be an algorithm. But for example "refRange" is clearly a
range specific thing, but "transpose" is not. And things that
create ranges from nothing also may "clearly" belong in the range
module? (e.g. iota, generate and recurrence)

Also curious, are there any github PRs in phobos where certain
algorithms were discussed as going in to where and what the
reasonings were?

cheers
- Ali
```
Jul 14 2018
Andrei Alexandrescu <SeeWebsiteForEmail erdani.com> writes:
```On 7/14/18 5:32 PM, aliak wrote:
Alo, I'm wondering how phobos devs view or determine what goes in to
std.algorithm and what goes in to std.range.

To me some of them are quite obvious - well, most things can arguably be
an algorithm. But for example "refRange" is clearly a range specific
thing, but "transpose" is not. And things that create ranges from
nothing also may "clearly" belong in the range module? (e.g. iota,
generate and recurrence)

Also curious, are there any github PRs in phobos where certain
algorithms were discussed as going in to where and what the reasonings
were?

cheers
- Ali

There is no hard and fast rule. If it does something one would naturally
associate with an algorithm (e.g. it would belong in a book on
algorithms etc), it belongs in std.algorithm even if it processes
ranges. If something is algorithmically trivial but support ranges, then
it belongs in std.range.

Without looking: where should "chain" belong? It's a trivial algorithm
but has a variety of intricacies for supporting different kinds of
ranges. So it's in std.range.

Andrei
```
Jul 16 2018