SlideShare a Scribd company logo
1 of 30
Download to read offline
ClojureBridge Helsinki
17.05.2015
Tervetuloa
@SolitaOy @metosin
Agenda
10:00
13:00
15:00
17:00
Welcome
Our goals
First steps in programming
Lunch
Programming in real life
More programming
Break
Even more programming
We're done
Agenda
Our goals
(+ 3 4)

(max 8 17 2)

(eat "sandwich")
;; more food code

(eat "cookie") ; nom nom nom

(eat "donut") ; mmm donuts
(+ 1 1) ;=> 1 + 1 = 2

(- 12 4) ;=> 12 - 4 = 8

(* 13 2) ;=> 13 * 2 = 26

(/ 27 9) ;=> 27 / 9 = 3
Infix:
Prefix:
1 + 2 * 3 / 4 + 5 - 6 * 7 / 8 + 9
(+ (- (+ (+ 1 (/ (* 2 3) 4)) 5) (/ (* 6 7) 8)) 9)
Infix:
Prefix:
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
(+ 1 2 3 4 5 6 7 8 9)
Infix:
Prefix:
1 + 2 * 3 / 4 + 5 - 6 * 7 / 8 + 9
(+ (- (+ (+ 1 (/ (* 2 3) 4)) 5) (/ (* 6 7) 8)) 9)
Open terminal
Open LightTable
File -> Open folder -> clojurebridge
(+ 4/3 7/8) ;=> 53/24

(- 9 4.2 1/2) ;=> 4.3

(/ 27/2 1.5) ;=> 9.0
;; strings

"Salut tout le monde"

"Prost!"



;; keywords

:surname

:birth-date

:r2



;; booleans

true

false
(def mangoes 3)

(def oranges 5)

(+ mangoes oranges) ;=> 8
(def fruit (+ mangoes oranges))

(def average-fruit-amount (/ fruit 2))

average-fruit-amount ;=> 4
Excercise
• Define a symbol with value of your height
in centimetres
• Define another symbol that holds your
height in inches
• Ask height of your neighbours and
calculate the average of all heights
One inch is 2.54 centimetres
Average: sum of values divided by number of values
Data-structures
["a" "b" "c" "d" "e" "f"]["a" "b" "c" "d" "e" "f"]
[1 2 3 4]

["Answer" 42]

[]

[[1 2 3] ["a" "b" "c"]]
(count [5 10 15]) ;=> 3



(nth [5 10 15] 1) ;=> 10



(first [5 10 15]) ;=> 5



(rest [5 10 15]) ;=> (10 15)



(conj [5 10] 15) ;=> [5 10 15]
Excercise
• Define a vector containing the temperatures
of your home town for next 5 days
• Use nth function to check the temperature
in Tuesday
For example: http://ilmatieteenlaitos.fi
Functions
(defn reduced-price [price]

(* price 0.75))
(reduced-price 120) ;=> 90
(reduced-price 10) ;=> 7.5

(reduced-price 0) ;=> 0.0
(defn reduced-price [price]

(* price 0.75))
(reduced-price 120) ;=> 90
(reduced-price 10) ;=> 7.5

(reduced-price 0) ;=> 0.0
(defn reduced-price [price reduce-by]

(* price reduce-by))



(reduced-price 120 0.75) ;=> 90.0

(reduced-price 120 0.50) ;=> 60.0
(defn reduced-price [price reduce-by]

(* price reduce-by))



(reduced-price 120 0.75) ;=> 90.0

(reduced-price 120 0.50) ;=> 60.0
(defn reduced-price [price reduce-pct]

(* price (- 1.0 (/ reduce-pct 100.0))))



(reduced-price 120 25) ;=> 90.0

(reduced-price 120 50) ;=> 60.0
(defn reduced-price [price reduce-by]

(* price reduce-by))



(reduced-price 120 0.75) ;=> 90.0

(reduced-price 120 0.50) ;=> 60.0
(defn reduced-price [price reduce-pct]

(* price (- 1.0 (/ reduce-pct 100.0))))



(reduced-price 120 25) ;=> 90.0

(reduced-price 120 50) ;=> 60.0
(defn reduced-price [price reduce-pct]

(let [one-percent (/ price 100.0)

discount (* one-percent reduce-pct)]

(- price discount)))
(defn reduced-price [price reduce-pct]

(* price (- 1.0 (/ reduce-pct 100.0))))



(reduced-price 120 25) ;=> 90.0

(reduced-price 120 50) ;=> 60.0
(defn reduced-price [price reduce-pct]

(let [one-percent (/ price 100.0)

discount (* one-percent reduce-pct)]

(- price discount)))
(defn reduced-price [price reduce-pct]

(let [one-percent (/ price 100.0)

discount (* one-percent reduce-pct)]

(- price discount)))
(defn major-sale [price]

(reduced-price price 40))
(map major-sale [120.0 100.0 30.0])
;=> (72.0 60.0 18.0)

More Related Content

Similar to ClojureBridge Helsinki Agenda and Code Samples

Similar to ClojureBridge Helsinki Agenda and Code Samples (20)

C arrays
C arraysC arrays
C arrays
 
Very basic functional design patterns
Very basic functional design patternsVery basic functional design patterns
Very basic functional design patterns
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cython
 
Programming meeting #4
Programming meeting #4Programming meeting #4
Programming meeting #4
 
Market Basket Analysis in R
Market Basket Analysis in RMarket Basket Analysis in R
Market Basket Analysis in R
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 Simplified
 
pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기
 
Students Management System c++ project.pptx
Students Management System c++ project.pptxStudents Management System c++ project.pptx
Students Management System c++ project.pptx
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
7. arrays
7. arrays7. arrays
7. arrays
 
Groovy kind of test
Groovy kind of testGroovy kind of test
Groovy kind of test
 
Groovy kind of test
Groovy kind of testGroovy kind of test
Groovy kind of test
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Rust
RustRust
Rust
 
Ch7
Ch7Ch7
Ch7
 
Ch7
Ch7Ch7
Ch7
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Advanced patterns in asynchronous programming
Advanced patterns in asynchronous programmingAdvanced patterns in asynchronous programming
Advanced patterns in asynchronous programming
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

ClojureBridge Helsinki Agenda and Code Samples

  • 5. 10:00 13:00 15:00 17:00 Welcome Our goals First steps in programming Lunch Programming in real life More programming Break Even more programming We're done Agenda
  • 7. (+ 3 4)
 (max 8 17 2)
 (eat "sandwich")
  • 8. ;; more food code
 (eat "cookie") ; nom nom nom
 (eat "donut") ; mmm donuts
  • 9. (+ 1 1) ;=> 1 + 1 = 2
 (- 12 4) ;=> 12 - 4 = 8
 (* 13 2) ;=> 13 * 2 = 26
 (/ 27 9) ;=> 27 / 9 = 3
  • 10. Infix: Prefix: 1 + 2 * 3 / 4 + 5 - 6 * 7 / 8 + 9 (+ (- (+ (+ 1 (/ (* 2 3) 4)) 5) (/ (* 6 7) 8)) 9)
  • 11. Infix: Prefix: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 (+ 1 2 3 4 5 6 7 8 9) Infix: Prefix: 1 + 2 * 3 / 4 + 5 - 6 * 7 / 8 + 9 (+ (- (+ (+ 1 (/ (* 2 3) 4)) 5) (/ (* 6 7) 8)) 9)
  • 12. Open terminal Open LightTable File -> Open folder -> clojurebridge
  • 13. (+ 4/3 7/8) ;=> 53/24
 (- 9 4.2 1/2) ;=> 4.3
 (/ 27/2 1.5) ;=> 9.0
  • 14. ;; strings
 "Salut tout le monde"
 "Prost!"
 
 ;; keywords
 :surname
 :birth-date
 :r2
 
 ;; booleans
 true
 false
  • 15. (def mangoes 3)
 (def oranges 5)
 (+ mangoes oranges) ;=> 8 (def fruit (+ mangoes oranges))
 (def average-fruit-amount (/ fruit 2))
 average-fruit-amount ;=> 4
  • 16. Excercise • Define a symbol with value of your height in centimetres • Define another symbol that holds your height in inches • Ask height of your neighbours and calculate the average of all heights One inch is 2.54 centimetres Average: sum of values divided by number of values
  • 18.
  • 19. ["a" "b" "c" "d" "e" "f"]["a" "b" "c" "d" "e" "f"] [1 2 3 4]
 ["Answer" 42]
 []
 [[1 2 3] ["a" "b" "c"]]
  • 20. (count [5 10 15]) ;=> 3
 
 (nth [5 10 15] 1) ;=> 10
 
 (first [5 10 15]) ;=> 5
 
 (rest [5 10 15]) ;=> (10 15)
 
 (conj [5 10] 15) ;=> [5 10 15]
  • 21. Excercise • Define a vector containing the temperatures of your home town for next 5 days • Use nth function to check the temperature in Tuesday For example: http://ilmatieteenlaitos.fi
  • 23. (defn reduced-price [price]
 (* price 0.75)) (reduced-price 120) ;=> 90 (reduced-price 10) ;=> 7.5
 (reduced-price 0) ;=> 0.0
  • 24. (defn reduced-price [price]
 (* price 0.75)) (reduced-price 120) ;=> 90 (reduced-price 10) ;=> 7.5
 (reduced-price 0) ;=> 0.0 (defn reduced-price [price reduce-by]
 (* price reduce-by))
 
 (reduced-price 120 0.75) ;=> 90.0
 (reduced-price 120 0.50) ;=> 60.0
  • 25. (defn reduced-price [price reduce-by]
 (* price reduce-by))
 
 (reduced-price 120 0.75) ;=> 90.0
 (reduced-price 120 0.50) ;=> 60.0
  • 26. (defn reduced-price [price reduce-pct]
 (* price (- 1.0 (/ reduce-pct 100.0))))
 
 (reduced-price 120 25) ;=> 90.0
 (reduced-price 120 50) ;=> 60.0 (defn reduced-price [price reduce-by]
 (* price reduce-by))
 
 (reduced-price 120 0.75) ;=> 90.0
 (reduced-price 120 0.50) ;=> 60.0
  • 27. (defn reduced-price [price reduce-pct]
 (* price (- 1.0 (/ reduce-pct 100.0))))
 
 (reduced-price 120 25) ;=> 90.0
 (reduced-price 120 50) ;=> 60.0
  • 28. (defn reduced-price [price reduce-pct]
 (let [one-percent (/ price 100.0)
 discount (* one-percent reduce-pct)]
 (- price discount))) (defn reduced-price [price reduce-pct]
 (* price (- 1.0 (/ reduce-pct 100.0))))
 
 (reduced-price 120 25) ;=> 90.0
 (reduced-price 120 50) ;=> 60.0
  • 29. (defn reduced-price [price reduce-pct]
 (let [one-percent (/ price 100.0)
 discount (* one-percent reduce-pct)]
 (- price discount)))
  • 30. (defn reduced-price [price reduce-pct]
 (let [one-percent (/ price 100.0)
 discount (* one-percent reduce-pct)]
 (- price discount))) (defn major-sale [price]
 (reduced-price price 40)) (map major-sale [120.0 100.0 30.0]) ;=> (72.0 60.0 18.0)