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

com.natpryce.zip.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.natpryce

inline fun  zip(
    r1: Result,
    transform: (T1) -> U
): Result =
    r1.map(transform)

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

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy