Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
分解に救われる
Search
valerauko
May 24, 2018
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
分解に救われる
地球はプラに、開発者の脳は複雑な引数指定に襲われてる。両方とも分解で解決できる。
Clojureの引数分解 (parameter destructuring) の軽いご紹介。
valerauko
May 24, 2018
More Decks by valerauko
See All by valerauko
CIにどこまで任せるのか?
valerauko
0
250
Reitit使ってみた
valerauko
0
410
Other Decks in Programming
See All in Programming
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
130
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
480
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
590
sbt 2.0: takeoff
eed3si9n
0
160
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
0
170
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
3.6k
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
Building an army of robots
kneath
307
47k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
How GitHub (no longer) Works
holman
316
150k
What's in a price? How to price your products and services
michaelherold
247
13k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
Facilitating Awesome Meetings
lara
57
7.2k
Transcript
引数で地球を救う 引数分解に惚れてしまった話
Erdos Balint • 株式会社スタディストでTeachme Biz開発 • ビール、⾳楽とプログラミング⼤好き • ⾃然を守ることを意識 @valerauko
⼤⾃然を守るのは⼈類の責任 プラスチック のゴミをなん とかしないと いけない
プラ汚染をなんとかするために u使う量を減らす u捨てる時に分ける uゴミを無害化する
プラ汚染をなんとかするために u使う量を減らす u捨てる時に分ける uゴミを無害化する
プラ汚染をなんとかするために u使う量を減らす u捨てる時に分ける uゴミを無害化する
プラ汚染をなんとかするために u使う量を減らす u捨てる時に分ける uゴミを無害化する 京⼯⼤・慶應の研究者が PETを分解する微⽣物を発⾒
引数が多いとわかりにくい 引数の意味がわからない 引数の必要性もわからない 問題
ハッシュマップを渡してみる 「すべて」は取れないネストされた ハッシュは分解できない 問題
分解に救われる 地球も正気も
羅列を分解 user=> (defn hoge #_=> "&でその他が取れる" #_=> [param1 & others]
#_=> (list param1 others)) #'user/hoge user=> (hoge "fuga" 3.14 42) ("fuga" (3.14 42))
羅列を分解 user=> (defn hoge #_=> "いらない要素は無視できる" #_=> [_ param1 param2]
#_=> (list param1 param2)) #'user/hoge user=> (hoge "fuga" 42 :konkon) (42 :konkon)
羅列を分解 user=> (defn hoge #_=> "ネストされた羅列も分解できる" #_=> [p1 [_ v1]
p2] #_=> (list p1 v1 p2)) #'user/hoge user=> (hoge "fuga" [3.14 42] :konkon) ("fuga" 42 :konkon) user=> (hoge 3.14 "abc" :konkon)
羅列を分解 user=> (defn hoge #_=> ":asで全ても取れる" #_=> [p1 [_ p3
:as meaning] p4] #_=> (list p1 p3 p4 meaning)) #'user/hoge user=> (hoge "fuga" [3.14 42] :konkon) ("fuga" 42 :konkon [3.14 42])
連装連想分解 user=> (def person #_=> {:name "Balint" #_=> :city "Tokyo"
#_=> :like ["Clojure" "beer" #_=> "music" "mobage"]}) #'user/person
連装連想分解 user=> (defn say-hello #_=> "マップから欲しいキーだけ取れる" #_=> [{name :name city
:city}] #_=> (str "Hello " name #_=> ", how is " city "?")) #'user/say-hello user=> (say-hello person) "Hello Balint, how is Tokyo?"
連装連想分解 user=> (defn say-hello #_=> ":orでデフォルト値⼊れられる" #_=> [{name :name :or
{name "Foo"}] #_=> (str "Hello, " name "!")) #'user/say-hello user=> (say-hello {}) "Hello, Foo!"
連装連想分解 user=> (defn say-hello #_=> ":keys :strs :symsで短略に書ける" #_=> [{:keys
[name city]}] #_=> (str "Hello " name #_=> ", how is " city "?")) #'user/say-hello user=> (say-hello person) "Hello Balint, how is Tokyo?"
連装連想分解 user=> (defn say-hello #_=> "好きに組み合わせもできる" #_=> [{:keys [name city]
:or {name "Guest"} #_=> [like :as likes] :like}] #_=> (println (str "Hello, " name "! " #_=> "How is " like " in " city "?")) #_=> likes) #'user/say-hello user=> (say-hello person) Hello, Balint! How is Clojure in Tokyo? ["Clojure" "beer" "music" "mobage"]
必要か? 複雑なデータ構造をその ままで渡して、それぞれ の関数で必要なものだけ 抜けられるので⾮常に便 利。 (def person {"@context" "https://example.com/#ns"
:name ["Erdos" "Balint"] :location {:country "Japan" :city "Tokyo"} :likes ["Clojure" "beer" "music" "mobage"] :work {:company "Studist" :position "Developer"} :skills {:language ["Hungarian" "English" "Japanese"] :code ["Ruby" "Python" "Clojure" "JavaScript" "SQL"]} :refs [{:url "https://balint.erdos.tech" :rel "Website"} {:url "https://github.com/valerauko" :rel "GitHub"} {:url "https://pawoo.net/@valerauko" :rel "Mastodon"}]})
We’re hiring! Ruby on Rails, Vue.js, AWS