All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.forkhandles.result4k.flatZip.kt Maven / Gradle / Ivy

There is a newer version: 2.20.0.0
Show newest version
package dev.forkhandles.result4k

inline fun  flatZip(
    r1: Result,
    transform: (T1) -> Result
): Result =
    r1.flatMap(transform)

inline fun  flatZip(
    r1: Result,
    r2: Result,
    transform: (T1, T2) -> Result
): Result =
    r1.flatMap { v1 ->
        r2.flatMap { v2 ->
            transform(v1, v2)
        }
    }

inline fun  flatZip(
    r1: Result,
    r2: Result,
    r3: Result,
    transform: (T1, T2, T3) -> Result
): Result =
    r1.flatMap { v1 ->
        r2.flatMap { v2 ->
            r3.flatMap { v3 ->
                transform(v1, v2, v3)
            }
        }
    }

inline fun  flatZip(
    r1: Result,
    r2: Result,
    r3: Result,
    r4: Result,
    transform: (T1, T2, T3, T4) -> Result
): Result =
    r1.flatMap { v1 ->
        r2.flatMap { v2 ->
            r3.flatMap { v3 ->
                r4.flatMap { v4 ->
                    transform(v1, v2, v3, v4)
                }
            }
        }
    }

inline fun  flatZip(
    r1: Result,
    r2: Result,
    r3: Result,
    r4: Result,
    r5: Result,
    transform: (T1, T2, T3, T4, T5) -> Result
): Result =
    r1.flatMap { v1 ->
        r2.flatMap { v2 ->
            r3.flatMap { v3 ->
                r4.flatMap { v4 ->
                    r5.flatMap { v5 ->
                        transform(v1, v2, v3, v4, v5)
                    }
                }
            }
        }
    }

inline fun  flatZip(
    r1: Result,
    r2: Result,
    r3: Result,
    r4: Result,
    r5: Result,
    r6: Result,
    transform: (T1, T2, T3, T4, T5, T6) -> Result
): Result =
    r1.flatMap { v1 ->
        r2.flatMap { v2 ->
            r3.flatMap { v3 ->
                r4.flatMap { v4 ->
                    r5.flatMap { v5 ->
                        r6.flatMap { v6 ->
                            transform(v1, v2, v3, v4, v5, v6)
                        }
                    }
                }
            }
        }
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy