I am trying to write a mapfunction as curried and flipped. (First conversion function, then collection). I wrote a function and the compiler accepted it. But I canβt call it. The compiler gives a lack of mapfunc with the arguments supplied. Anyway, here is what I wrote:
func map <A: CollectionType, B> (f: (A.Generator.Element) -> B) -> A -> [B] {
return { map($0, f) }
}
And this is the test code:
func square(a: Int) -> Int {
return a * a
}
map(square)
Note. The code is written inside the playground with Xcode 6.3 beta 2
source
share