com.github.mperry.fg.StateInt.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalgroovy-main Show documentation
Show all versions of functionalgroovy-main Show documentation
FunctionalGroovy enhances FunctionalJava for Groovy
package com.github.mperry.fg
import fj.F
import fj.P2
import groovy.transform.Canonical
import groovy.transform.TypeChecked
/**
* Created by MarkPerry on 9/01/14.
*/
@TypeChecked
@Canonical
class StateInt extends State {
StateInt(F> f) {
run = f
}
def StateInt flatMap(F> f) {
new StateInt({ Integer s ->
def p = run.f(s)
def a = p._1()
def s2 = p._2()
def sib = f.f(a)
sib.run.f(s2)
} as F)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy