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
Clojure
Search
Samuel Flores
November 29, 2014
Programming
4
200
Clojure
Apresentando Clojure hoje no encontro do GuruPI
Samuel Flores
November 29, 2014
Tweet
Share
More Decks by Samuel Flores
See All by Samuel Flores
Introdução ao MRuby
samflores
1
56
Gulp.js
samflores
1
150
Por que Ruby?
samflores
1
140
Extendendo Ruby com C (& cartoons)
samflores
3
180
Sinatra
samflores
2
220
Other Decks in Programming
See All in Programming
Kotlin 2.2が切り拓く: コンテキストパラメータで書く関数型DSLと新しい依存管理のかたち
knih
0
420
Blazing Fast UI Development with Compose Hot Reload (droidcon London 2025)
zsmb
0
500
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
270
競馬で学ぶ機械学習の基本と実践 / Machine Learning with Horse Racing
shoheimitani
10
8.4k
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
9
3.9k
「10分以内に機能を消せる状態」 の実現のためにやっていること
togishima
1
270
r2-image-worker
yusukebe
1
170
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
4
680
しっかり学ぶ java.lang.*
nagise
1
250
問題の見方を変える「システム思考」超入門
panda_program
0
190
Functional Calisthenics in Kotlin: Kotlinで「関数型エクササイズ」を実践しよう
lagenorhynque
0
130
組織もソフトウェアも難しく考えない、もっとシンプルな考え方で設計する #phpconfuk
o0h
PRO
10
4.1k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Why You Should Never Use an ORM
jnunemaker
PRO
60
9.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
What's in a price? How to price your products and services
michaelherold
246
12k
Bash Introduction
62gerente
615
210k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The Invisible Side of Design
smashingmag
302
51k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Transcript
(Clojure) @samflores
Lisp
Lots of InSignificant Parenthesis
LISt Processing
(1 2 3) *
Homoiconicidade
(+ 2 3) ; 5
(+ 2 4 6) ; 12
(doc +) clojure.core/+ ([] [x] [x y] [x y &
more]) Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'
Funcional
(odd? 2) ; false
(def par? (fn [n] (even? n))) (par? 2); true
(def par? even?) (par? 2); true
(defn greet [name] (str "Hello, " name)) (greet "John"); Hello,
John
(map :name [{:name "John" :age 15} {:name "Mary" :age 10}])
(reduce + (range 10))
(apply + (repeat 30 8)) ; 240
(def dobra (partial * 2)) (dobra 5) ; 10
Simplicidade
def fn #() if do let quote ‘() var #’()
loop recur throw try formas especiais
alias and BEGIN begin break case class def defined? do
else elsif END end ensure for if in module next not or redo rescue retry return self super then undef unless until when while yield Ruby
assert break class const continue default do double else enum
extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while Java
Pragmatismo
(def b 2r101010) (def n 1337N) (def m 3.14159M) (def
r #"(\d+)") data types
(def l '(1 2 3)) (def v [1 2 3])
(def m {:a 1 :b 2}) (def s #{:x :y :z}) data types
JVM*
(def today (java.Util.Date.)) (.year today) ; today.year() (Integer/parseInt "10") Java
interop
Imutabilidade*
(def l '(1)) (conj l 2) (prn l) ; (1)
& Concorrência Paralelismo
STM atoms agents delays futures promisses refs core.async …
(def l (atom [])) (swap! l conj 1) atoms
(def c (agent 0)) (send c inc) (send c dec)
(await c) agents
(defn long-running-job [n] (Thread/sleep 3000) (+ n 10)) (pmap long-running-job
(range 100)) pmap
(def ch (chan)) (go (print (<! ch))) (put! ch "Hi")
core.async
Environment
(defroute "/" [] (home-handler)) (defroute "/:user” [user] (profile-handler user)) compojure
:dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/core.async "0.1.346.0-17112a-alpha"]] leiningen
$ lein deps $ lein ring server leiningen
(select user (with address) (fields :firstName :lastName :address.state) (where {:email
"
[email protected]
"})) korma
ClojureScript core.typed datomic Clojars jetty http-kit …
Comunidade
clojure.org clojure-doc.org clojuredocs.org grimoire.arrdem.com #clojure FreeNode
(obrigado) @samflores