the structure and elements of computer programs, that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data — Wiki
boilerplate part Functions is a Type, the same as Int var a: Int = 10 var b: () -> () // sayHello(), will print hello to console b = sayHello var d: Int -> Bool // isOdd(10) - false var e: (Int -> Bool) -> Int // filter(isOdd(10))
array of numbers, I want to get only odd numbers. I have an array of numbers, takes yeach element, check if it's odd, add it to the result array and return
...}, {"name" : "Siri", ...}, {"name" : "Lori", ...}, {"name" : "Mari", ...}] We know how to transform 1 Cat Now we want to do it for every element let result = Aray() for elemt in catsJSON { let cat = catify(elemt) result.add(cat) }