This is my first post on DEV. I did not expect to have a lot of readers for my first post, but it's my most read by far. I think maybe DEV promotes first posts? dev.to/sethcalebweeks/haskell-quic...
Fun read, and a good use of the algorithm as a vehicle for explaining Haskell syntax rather than the other way round.
Coming from C#, the same shape falls out of LINQ almost unchanged:
static IEnumerable<T> Qs<T>(IReadOnlyList<T> xs) where T : IComparable<T> => xs.Count == 0 ? Enumerable.Empty<T>() : Qs(xs.Skip(1).Where(a => a.CompareTo(xs[0]) <= 0).ToList()) .Append(xs[0]) .Concat(Qs(xs.Skip(1).Where(a => a.CompareTo(xs[0]) > 0).ToList()));
Some comments have been hidden by the post's author - find out more
We're a place where coders share, stay up-to-date and grow their careers.
This is my first post on DEV. I did not expect to have a lot of readers for my first post, but it's my most read by far. I think maybe DEV promotes first posts?
dev.to/sethcalebweeks/haskell-quic...
Fun read, and a good use of the algorithm as a vehicle for explaining Haskell syntax rather than the other way round.
Coming from C#, the same shape falls out of LINQ almost unchanged: