SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
Clojure
Calc

(defn calc [op v1 v2]
   (cond (= "+" op) (+ v1 v2)
         (= "-" op) (- v1 v2)
          (= "*" op) (* v1 v2)
          (= "/" op) (/ v1 v2)
))
Set - Intersection
user=> (clojure.core/refer 'clojure.set)
user=> (def s #{1 2 3 4 })
user=> (def s2 #{3 4 5 6 7})
user=> (intersection s)
#{1 2 3 4}
user=> (intersection s s2)
#{3 4}
user=> (def s3 #{2 3 9 0})
user=> (intersection s s2 s3)
#{3}
Set - Difference
user=> (difference s)
#{1 2 3 4}
user=> (difference s s2)
#{1 2}
user=> (difference s s2 s3)
#{1}
Set - Union
user=> (union s)
#{1 2 3 4}
user=> (union s s2)
#{1 2 3 4 5 6 7}
user=> (union s s2 s3)
#{0 1 2 3 4 5 6 7 9}

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (8)

Simple flat ui css accordion
Simple flat ui css accordionSimple flat ui css accordion
Simple flat ui css accordion
 
Rafael torrest
Rafael torrestRafael torrest
Rafael torrest
 
Excerpt
ExcerptExcerpt
Excerpt
 
Excerpt
ExcerptExcerpt
Excerpt
 
Numeros primos
Numeros primosNumeros primos
Numeros primos
 
Assignment
AssignmentAssignment
Assignment
 
Some logics
Some logicsSome logics
Some logics
 
Volley cert
Volley certVolley cert
Volley cert
 

Andere mochten auch

Andere mochten auch (7)

Clojure lightning talk
Clojure lightning talkClojure lightning talk
Clojure lightning talk
 
Patch in 5 minutes
Patch in 5 minutesPatch in 5 minutes
Patch in 5 minutes
 
Reactive application
Reactive applicationReactive application
Reactive application
 
Book club presentation kanban
Book club presentation   kanbanBook club presentation   kanban
Book club presentation kanban
 
Continuous deployment in 15 minutes
Continuous deployment in 15 minutesContinuous deployment in 15 minutes
Continuous deployment in 15 minutes
 
Refactoring techniques
Refactoring techniquesRefactoring techniques
Refactoring techniques
 
Gpars 5-minutes
Gpars 5-minutesGpars 5-minutes
Gpars 5-minutes
 

Mehr von Christophe Marchal (20)

Elasticsearch avoiding hotspots
Elasticsearch  avoiding hotspotsElasticsearch  avoiding hotspots
Elasticsearch avoiding hotspots
 
Performance
PerformancePerformance
Performance
 
Alluxio
AlluxioAlluxio
Alluxio
 
Elasticsearch cluster deep dive
Elasticsearch  cluster deep diveElasticsearch  cluster deep dive
Elasticsearch cluster deep dive
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Reactive programming with Rxjava
Reactive programming with RxjavaReactive programming with Rxjava
Reactive programming with Rxjava
 
Terraform
TerraformTerraform
Terraform
 
Consul in 5 minutes
Consul in 5 minutesConsul in 5 minutes
Consul in 5 minutes
 
Spark in 15 min
Spark in 15 minSpark in 15 min
Spark in 15 min
 
Microservices Architecture: Nirvana or Nightmare
Microservices Architecture: Nirvana or NightmareMicroservices Architecture: Nirvana or Nightmare
Microservices Architecture: Nirvana or Nightmare
 
Capistrano
CapistranoCapistrano
Capistrano
 
Aws, play! couch db scaling soa in the cloud
Aws, play! couch db  scaling soa in the cloudAws, play! couch db  scaling soa in the cloud
Aws, play! couch db scaling soa in the cloud
 
Devops e a nova cultura - TDC Florianopolis 2015
Devops e a nova cultura - TDC Florianopolis 2015Devops e a nova cultura - TDC Florianopolis 2015
Devops e a nova cultura - TDC Florianopolis 2015
 
Devops and the New Culture
Devops and the New CultureDevops and the New Culture
Devops and the New Culture
 
CUDA
CUDACUDA
CUDA
 
Monads in practice
Monads in practiceMonads in practice
Monads in practice
 
Productivity and scalability with Play and Scala
Productivity and scalability with Play and ScalaProductivity and scalability with Play and Scala
Productivity and scalability with Play and Scala
 
Internet of things and arduino
Internet of things and arduinoInternet of things and arduino
Internet of things and arduino
 
Hbase
HbaseHbase
Hbase
 
Integration with hdfs using WebDFS and NFS
Integration with hdfs using WebDFS and NFSIntegration with hdfs using WebDFS and NFS
Integration with hdfs using WebDFS and NFS
 

Clojure lightning talk

  • 2. Calc (defn calc [op v1 v2] (cond (= "+" op) (+ v1 v2) (= "-" op) (- v1 v2) (= "*" op) (* v1 v2) (= "/" op) (/ v1 v2) ))
  • 3. Set - Intersection user=> (clojure.core/refer 'clojure.set) user=> (def s #{1 2 3 4 }) user=> (def s2 #{3 4 5 6 7}) user=> (intersection s) #{1 2 3 4} user=> (intersection s s2) #{3 4} user=> (def s3 #{2 3 9 0}) user=> (intersection s s2 s3) #{3}
  • 4. Set - Difference user=> (difference s) #{1 2 3 4} user=> (difference s s2) #{1 2} user=> (difference s s2 s3) #{1}
  • 5. Set - Union user=> (union s) #{1 2 3 4} user=> (union s s2) #{1 2 3 4 5 6 7} user=> (union s s2 s3) #{0 1 2 3 4 5 6 7 9}