Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Functional Programming

Swift Functional Programming

(car (cdr ファンクション倶楽部)) https://esminc.connpass.com/event/57534/ で話そうと思ってたやつ

Hirofumi Wakasugi

September 24, 2017
Tweet

More Decks by Hirofumi Wakasugi

Other Decks in Programming

Transcript

  1. 4XJGUؔ਺ܕϓϩάϥϛϯά let list: List = .cons("pork", .cons("beef", .cons("chicken", .null))) //

    => (pork . (beef . (chicken . ()))) car(list) // => pork cdr(list) // => (beef . (chicken . ())) car(cdr(list)) // => beef cdr(cdr(list)) // => (chicken . ())
  2. 8IZ4XJGU  ͳͥ4XJGUͷ࿩Λ͢Δͷ͔ͷઆ໌  4XJGUͰؔ਺ܕϓϩάϥϛϯάͷ࣮ફ * ίʔυͷ࣮ྫɺέʔεελσΟ ** ؔ਺ܕϓϩάϥϛϯάͷͨΊͷϥΠϒϥϦͷ঺հ ***

    4%, $PDPB ʹΑΔ੍ݶͱͦͷXPSLBSPVOE ؔ਺ܕϓϩάϥϛϯάελΠϧͰͷ8FCϓϩάϥϛϯά * 7BQPSͱ͍͏8"'Λ࢖ͬͯؔ਺ܕϓϩάϥϛϯάΛద༻ͯ͠ΈΔ ΞδΣϯμ
  3. 8IZ4XJGU  ͳͥ4XJGUͷ࿩Λ͢Δͷ͔ͷઆ໌  4XJGUͰؔ਺ܕϓϩάϥϛϯάͷ࣮ફ * ίʔυͷ࣮ྫɺέʔεελσΟ ** ؔ਺ܕϓϩάϥϛϯάͷͨΊͷϥΠϒϥϦͷ঺հ ***

    4%, $PDPB ʹΑΔ੍ݶͱͦͷXPSLBSPVOE ؔ਺ϓϩάϥϛϯάελΠϧͰͷ8FCϓϩάϥϛϯά * 7BQPSͱ͍͏8"'Λ࢖ͬͯؔ਺ܕϓϩάϥϛϯάΛద༻ͯ͠ΈΔ ΞδΣϯμ ࠓ೔࿩͢ͷ͸͜Ε͚ͩʂ
  4. /0

  5. ެࣜͳݟղ w"QQMFࣗ਎͸4XJGU͕ؔ਺ܕͩͱ͸શ͘ݴͬͯͳ͍ ͕ɺ101701ͳϓϩάϥϛϯάΛڧ͘ਪ঑ (WWDC 2015 - Building Better Apps with

    Value Types in Swift) (WWDC 2016 - Protocol and Value Oriented Programming in UIKit Apps) 001͔ΒͷύϥμΠϜγϑτ͸Ψν
  6. ެࣜͳݟղ “Objective-C without the C” implies something subtractive, but Swift

    dramatically expands the design space through the introduction of generics and functional programming concepts. - Chris Lattner
  7. 4XJGUͰ࣮૷ࡁ enum List<T> { case null indirect case cons(T, List<T>)

    } ˢ๯಄ͷϦετͷ࣮૷Ͱ΋࠶ؼ&OVNΛ࢖͍ͬͯΔ