Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ClojureScript のある生活
Search
ayato
December 16, 2015
Programming
3
2.9k
ClojureScript のある生活
ayato
December 16, 2015
Tweet
Share
More Decks by ayato
See All by ayato
Clojureという言語が私逹にもたらしたもの
ayato0211
6
2.9k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
230
Re:REPL-Driven Development
ayato0211
3
1.2k
Meta Template Engine
ayato0211
2
1k
超変換! Hiccup data structure!!
ayato0211
2
560
About Integrant
ayato0211
0
510
Muscle Assert
ayato0211
0
230
Clojureを用いたWebアプリケーション開発
ayato0211
2
3k
翻訳にまつわるエトセトラ
ayato0211
6
1.2k
Other Decks in Programming
See All in Programming
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.3k
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
360
Beyond ORM
77web
11
1.6k
Запуск 1С:УХ в крупном энтерпрайзе: мечта и реальность ПМа
lamodatech
0
950
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.9k
php-conference-japan-2024
tasuku43
0
430
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
150
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
450
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
3
2.7k
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
250
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
Building Applications with DynamoDB
mza
93
6.2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Designing Experiences People Love
moore
139
23k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Building Your Own Lightsaber
phodgson
104
6.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
A better future with KSS
kneath
238
17k
Practical Orchestrator
shlominoach
186
10k
GitHub's CSS Performance
jonrohan
1030
460k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Transcript
$MPKVSF4DSJQU ͕ ͋Δੜ׆ !@BZBUP@Q
ࣗݾհ +4Φδαϯ$MPKVSFΦδαϯ +BWB4DSJQUॳ৺ऀͰ͢ ࠓ$MPKVSF͔͠ॻ͍ͯͳ͍ਓ $ZCP[V4UBSUVQT *OD
͜Μͳܦݧ͋Γ·ͤΜ͔ʁ ྫ͑ΦϯϥΠϯγϣοϓΈ͍ͨͳγεςϜɻ
͜Μͳܦݧ͋Γ·ͤΜ͔ʁ Χʔτͷ߹ܭֹۚΛϑϩϯτΤϯυͱ αʔόʔαΠυ྆ํͰಉ͡ܭࢉΛ͢Δඞཁ͕͋Δɻ
͜Μͳܦݧ͋Γ·ͤΜ͔ʁ ͔͠͠ɺֹۚܭࢉͳͷͰͲͪΒʹ ಉ࣮͢͡Δͱ͍͏͜ͱͨ͘͠ͳ͍ɻ
͜Μͳܦݧ͋Γ·ͤΜ͔ʁ ߹ܭֹۚܭࢉ"1*Λୟ͖·ͬͯ͘ αʔόʔαΠυͰܭࢉͨ݁͠ՌΛϑϩϯτʹฦ͢
͜Μͳܦݧ͋Γ·ͤΜ͔ʁ ී௨ʹߟ͑ͯͭΒ͍ ඇಉظॲཧΛྻԽͨ͠ΓɺϝϞԽͨ͠Γେม
ͦ͜Ͱ$MPKVSF4DSJQUͰ͢Α 3FBEFS$POEJUJPOBMTͷ͓ӄͰ 8SJUFPODF SVOBOZXIFSF 5SBOTJUϑΥʔϚοτͰ γʔϜϨεͳσʔλ௨৴ ϑϩϯτΤϯυαʔόʔαΠυ $MPKVSFͷ͚ࣝͩͰॻ͚Δ
$MPKVSF4DSJQU "MU+4ͱ͍͏ΑΓ$MPKVSFͷλʔήοτ͕ +7.Ͱͳ͘+BWB4DSJQUʹͳͬͨͷ ΄ͱΜͲ$MPKVSFͱಉ͚ͩ͡ͲɺҰ෦ҧ͏ JOUFSPQͱ͔ϚΫϩ͑Δ͚Ͳॻ͚ͳ͍ͱ͔ ΤίγεςϜ͕ڧ͍ ͱͯ 'JHXIFFMͰ8FC1BDL).3ͱಉ
#SPXTFS3&1-ͰϒϥβڥऔΕΔ
3FBEFS$POEJUJPOBMT $MPKVSF͔Β͑ΔΑ͏ʹͳͬͨݴޠػೳ DMKD֦ுࢠͰఆ͓ٛͯ͘͠ͱ $MPKVSF$MPKVSF4DSJQUͲͪΒ͔ΒಡࠐՄೳ ݴޠಛ༗ͷ͚ͩΛࠩఆٛग़དྷΔ
;; dates (.getTime #?(:clj (java.util.Date.) :cljs (js/Date.))) ;; uris #?(
:clj (defn url-encode [string] (some-> string str (URLEncoder/encode "UTF-8") (.replace "+" "%20"))) :cljs (defn url-encode [string] (some-> string str (js/encodeURIComponent) (.replace "+" "%20")))) ;; reflection warnings #?(:clj (set! *warn-on-reflection* true)) 3FBEFS$POEJUJPOBMT
5SBOTJU $MPKVSFͰ༗໊ͳ$PHOJUFDUͷ࡞ͬͨ ৽͍͠σʔλϑΥʔϚοτ ϓϩάϥϜಉ࢜ͷίϛϡχέʔγϣϯʹ͑Δ ϢʔβʔఆٛܕใΛૹड৴͢Δ͜ͱ͕ग़དྷΔ ωετͨͨͩ͠ͷϚοϓྻͱάοόΠ
(ns transit-demo.core (:require [cognitect.transit :as transit]) (:import [java.io ByteArrayInputStream ByteArrayOutputStream]))
(def custom-writer (transit/write-handler-map {Cart (transit/write-handler (constantly "cart") #(:items %)) Item (transit/write-handler (constantly "item") #(apply vector (vals %)))})) (def out (ByteArrayOutputStream. 4096)) (def writer (transit/writer out :json {:handlers custom-writer})) 5SBOTJU
(defprotocol Calculatable (calculate [x])) (defrecord Cart [items] Calculatable (calculate [self]
(apply + (map calculate items)))) (defn new-cart [items] (map->Cart {:items items})) (defrecord Item [name price] Calculatable (calculate [self] (* price 1.08))) (defn new-item [name price] (map->Item {:name name, :price price})) 5SBOTJU
(def my-cart-data (new-cart [(new-item "Clojure Programming" 1000) (new-item "Clojure Applied"
2500)])) (transit/write writer my-cart-data) (.toString out) ;; => "[\"~#cart\",[[\"~#item\",[\"Clojure Programming\",1000]], ;; [\"^1\",[\"Clojure Applied\",2500]]]]" 5SBOTJU
(def custom-reader (transit/read-handler-map {"cart" (transit/read-handler new-cart) "item" (transit/read-handler #(apply new-item
%))})) (def in (ByteArrayInputStream. (.toByteArray out))) (def reader (transit/reader in :json {:handlers custom-reader})) (def my-cart-data' (transit/read reader)) (calculate my-cart-data') ;; => 3780.0 5SBOTJU
ͭ·Γ 5SBOTJU8SJUFS3FBEFS 5ZQF3FDPSE DMK DMKD DMKT 1SPUPDPM 4FSWFSTJEF $MJFOUTJEF
།Ұͷܽ 3BUJPܕ͕$MPKVSF4DSJQUͰαϙʔτ͞Εͳ͍ ϥΠϒϥϦͰղܾͰ͖ΔͷͰͳ͍
·ͱΊ 5SBOTJUϑΥʔϚοτͰγʔϜϨεʹ σʔλΛड͚ͤΔ 3FBEFS$POEJUJPOBMTͰϑϩϯτͱαʔόʔα ΠυͰඞཁͳॲཧΛڞ௨Խग़དྷΔ $MPKVSF࠷ߴʂ
Enjoy Clojure