diff --git a/Sources/Gen/Gen.swift b/Sources/Gen/Gen.swift
index 04c072e..d440db7 100644
--- a/Sources/Gen/Gen.swift
+++ b/Sources/Gen/Gen.swift
@@ -53,19 +53,6 @@ extension Gen {
}
}
-/// Combines two generators into a single one.
-///
-/// - Parameters:
-/// - a: A generator of `A`s.
-/// - b: A generator of `B`s.
-/// - Returns: A generator of `(A, B)` pairs.
-@inlinable
-public func zip(_ a: Gen, _ b: Gen) -> Gen<(A, B)> {
- return Gen<(A, B)> { rng in
- (a._run(&rng), b._run(&rng))
- }
-}
-
extension Gen {
/// Transforms a generator of `Value`s into a generator of `NewValue`s by transforming a value into a generator of `NewValue`s.
///
diff --git a/Sources/Gen/UIKit.swift b/Sources/Gen/UIKit.swift
index 14afadd..3f8210a 100644
--- a/Sources/Gen/UIKit.swift
+++ b/Sources/Gen/UIKit.swift
@@ -3,6 +3,6 @@
extension Gen where Value == UIColor {
public static let color = zip(.float(in: 0...1), .float(in: 0...1), .float(in: 0...1))
- .map { UIColor(red: $0, green: $1, blue: $2, alpha: 1) }
+ .map { (rgb: (Double, Double, Double)) in UIColor(red: rgb.0, green: rgb.1, blue: rgb.2, alpha: 1) }
}
#endif
diff --git a/Sources/Gen/Xoshiro.swift b/Sources/Gen/Xoshiro.swift
index 8fb7f59..1246243 100644
--- a/Sources/Gen/Xoshiro.swift
+++ b/Sources/Gen/Xoshiro.swift
@@ -6,10 +6,10 @@ public struct Xoshiro: RandomNumberGenerator {
@inlinable
public init() {
self.state = zip(
- .int(in: .min ... .max),
- .int(in: .min ... .max),
- .int(in: .min ... .max),
- .int(in: .min ... .max)
+ Gen.int(in: .min ... .max),
+ Gen.int(in: .min ... .max),
+ Gen.int(in: .min ... .max),
+ Gen.int(in: .min ... .max)
)
.run()
}
diff --git a/Sources/Gen/Zip.swift b/Sources/Gen/Zip.swift
index 9fa3095..d2a7dab 100644
--- a/Sources/Gen/Zip.swift
+++ b/Sources/Gen/Zip.swift
@@ -1,3 +1,28 @@
+#if swift(>=5.9)
+/// Combines multiple generators into a single one that produces a tuple containing values from each input generator.
+///
+/// - Parameter gens: A variadic sequence of generators, each producing a value of a distinct type.
+/// - Returns: A generator that produces a tuple of values generated by each input generator in the order they were provided.
+@inlinable
+public func zip(_ gens: repeat Gen) -> Gen<(repeat each Value)> {
+ return Gen<(repeat each Value)> { rng in
+ return (repeat (each gens)._run(&rng))
+ }
+}
+#else
+/// Combines two generators into a single one.
+///
+/// - Parameters:
+/// - a: A generator of `A`s.
+/// - b: A generator of `B`s.
+/// - Returns: A generator of `(A, B)` pairs.
+@inlinable
+public func zip(_ a: Gen, _ b: Gen) -> Gen<(A, B)> {
+ return Gen<(A, B)> { rng in
+ (a._run(&rng), b._run(&rng))
+ }
+}
+
@inlinable
public func zip(
_ a: Gen,
@@ -113,3 +138,4 @@ public func zip(
{
return zip(zip(a, b), c, d, e, f, g, h, i, j).map { ($0.0, $0.1, $1, $2, $3, $4, $5, $6, $7, $8) }
}
+#endif