Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Why nullable types?. Parent comment
extension NullableIteratorExtensions<T> on Iterator<T?> { T? reduce<T>(T? Function(T,T) f, T? x0) => this.moveNext() ? (this.reduce(f, (x0 == null || this.current == null) ? null : f(x0,current))) : x0; }
Of course this is all a bit easier to read if we use some syntax specially built for Monads such as Haskell's do syntax:
reduce f (head:tail) x0 = do { x <- x0 ; y <- head ; reduce f tail (f x y) } reduce f [] x0 = x0
There are no comments on this comment yet.
Of course this is all a bit easier to read if we use some syntax specially built for Monads such as Haskell's do syntax:
which has the advantage that it works for all Monads.