Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
.

Ivan Morozov allquantor

:shipit:
.
View GitHub Profile
View gist:936a7fceb7558879c4817a86ad20f32d
### Keybase proof
I hereby claim:
* I am allquantor on github.
* I am allquantor (https://keybase.io/allquantor) on keybase.
* I have a public key ASDLiMeVjPjBE92VGIo4aGRukCDk5zxUtywfDkgBdMVyJwo
To claim this, I am signing this object:
View Monads Fun
import java.util.function.Function;
public interface Functor<T, F extends Functor<?,?>> {
<R> F map(Function<T,R> f);
}
import java.util.function.Function;
public abstract class Monad<F, M extends Monad<?, ?>> implements Functor<F, M> {
View UnionSequence.scala
import scala.language._
// https://en.wikipedia.org/wiki/Disjoint-set_data_structure
// Not optimized version
// Supports only integer element sequences starting with 0, where n1 - n2 = -1
object UnionSequence {
def apply(elems: Int*): UnionSequence = {
new UnionSequence(Array(elems:_*) toIndexedSeq)
}