Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1.  
  2. struct User {
  3.  
  4. let id: Int
  5. let name: String
  6. let email: String?
  7.  
  8. static let create = curry(User.init) // ОШИБКА компиляции
  9.  
  10. init(id: Int, name: String, email: String?) {
  11. self.id = id
  12. self.name = name
  13. self.email = email
  14. }
  15.  
  16. init(id: Int, name: String) {
  17. self.id = id
  18. self.name = name
  19. self.email = .none
  20. }
  21. }
  22.  
  23.  
  24. func curry<A, B, R>(_ f: @escaping (A, B) -> R) -> ((A) -> ((B) -> R)) {
  25. return { a in
  26. { b in
  27. f(a, b)
  28. }
  29. }
  30. }
  31.  
  32. func curry<A, B, C, R>(_ f: @escaping (A, B, C) -> R) -> ((A) -> ((B) -> ((C) -> R))) {
  33. return { a in
  34. { b in
  35. { c in
  36. f(a, b, c)
  37. }
  38. }
  39. }
  40. }
  41.  
  42.  
  43. . . . . . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement