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
Verilogで学ぶCPU自作入門.pdf
uyuki234
2
1.3k
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
16
13k
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.3k
速習iPhone Duo対応
yuukiw00w
1
710
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
260
Intent as Code
shoppingjaws
6
1.1k
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
300
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3.1k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
310
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.9k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
0
150
Java 27新機能 / Java 27 new features
kishida
2
160
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5.2k
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Between Models and Reality
mayunak
4
460
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
730
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
460
Ethics towards AI in product and experience design
skipperchong
2
380
How GitHub (no longer) Works
holman
316
150k
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