New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zip function #3
Comments
I was actually basing my zip function on this one. zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith' _ [] _ = []
zipWith' _ _ [] = []
zipWith' f (x:xs) (y:ys) = f x y : zipWith' f xs ys And the example:
Something I was thinking was to pass a default function, in case we don't pass one. The default one, would be the same as your implementation: tuple creation. Something along the lines: func zip<X,Y,Z>(listX : [X], listY : [Y], zipFunction : (X,Y)-> W = ... ) -> [W] The ... would be replace by a default tuples creation function. |
@konstantinkoval I am good on changing the zip function to the official implementation, although I would like to keep the recursive piece. |
There is |
let zip = Zip2([1, 2, 3], [1, 2, 3])
let zippedArray = Array(myZip) Result:
|
I wanted to implement zip function
But i'm not sure if Tuples are designed to be used this way in Swift as in Haskell.
http://stackoverflow.com/questions/24487519/how-to-elegantly-compare-tuples-in-swift/24495112#24495112
What do you think ?
The text was updated successfully, but these errors were encountered: