---
# System prepended metadata

title: 2020-04-07 | Swift | Programmation fonctionnelle
tags: [swift, gobelins]

---

# 2020-04-07 | Swift | Programmation fonctionnelle

###### tags: `swift` `gobelins`

```swift
import Foundation

var array = [1.0,0.3,0.5,0.6]
var array2d = [
    [1.0,0.3,0.5,0.6],
    [1.0,0.3,0.5,0.6,14,14],
    [1.0,0.3,0.5,0.6,12,0.3,26]
]
var myWords = ["Bonjour","Au revoir","Vacances"]

var w = myWords.sorted{ $0 < $1 }
               .map{ String($0.reversed()) }
               .sorted{ $0.count < $1.count }
               .dropLast()
               .sorted{ $0.count > $1.count }
print(w)

let sum = w.reduce(0){ (res,str) ->Int in 
    return res + str.count
}

print(sum)
```