Purity

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
cyboryxmen
Posts: 180
Joined: November 14th, 2014, 2:03 am

Purity

Post by cyboryxmen » February 24th, 2019, 6:55 pm

Code: Select all

template<typename Buffer>
constexpr Buffer pureSort(const Buffer& buffer)
{
    if(!buffer.empty())
    {
        const auto middle = buffer.front();

        auto output = integers(1, buffer.size()) | scan([middle](auto buffer, auto i, auto divider)
        {
            auto temp = buffer[divider];
            auto current = buffer[i];
            auto buffer2 = buffer.set(current, temp).set(temp, current);
            return select(buffer2, divider + 1).where(buffer[i] < middle).otherwise(buffer, divider);
        }, buffer, 0) | select_last();

        return pureSort(pureSort(output()));
    }
    else
    {
        return buffer();
    }
}
😩👌
Zekilk

User avatar
chili
Site Admin
Posts: 3892
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Purity

Post by chili » February 25th, 2019, 10:16 am

what are these unauthorized smileys :evil:
Chili

Post Reply