Tutorials Point, posted on 6th Dec, 2017

Clojure Basic Syntax Hello World

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println "Hello World"))
(hello-world)

Tutorials Point, posted on 6th Dec, 2017

Clojure Basic Syntax General Form of a Statement

(ns clojure.examples.hello
   (:gen-class))
(defn Example []
   (println (str "Hello World"))
   (println (+ 1 2)))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Basic Syntax Delimiters

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (println (+ 1 2 3)))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Example2 Delimiters

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (println [+ 1 2 3]))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Data Types

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   ;; The below code declares a integer variable
   (def x 1)
   
   ;; The below code declares a float variable
   (def y 1.25)
   
   ;; The below code declares a string variable
   (def str1 "Hello")
   (println x)
   (println y)
   (println str1))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Variables

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   ;; The below code declares a integer variable
   (def x 1)
   
   ;; The below code declares a float variable
   (def y 1.25)
   
   ;; The below code declares a string variable
   (def str1 "Hello")
   (println x)
   (println y)
   (println str1))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Arithmetic Operators

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def x (+ 2 2))
   (println x)
   
   (def x (- 2 1))
   (println x)
   
   (def x (* 2 2))
   (println x)
   
   (def x (float(/ 2 1)))
   (println x)
   
   (def x (inc 2))
   (println x)
   
   (def x (dec 2))
   (println x)
   
   (def x (max 1 2 3))
   (println x)
   
   (def x (min 1 2 3))
   (println x)
   
   (def x (rem 3 2))
   (println x))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Relational Operators

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def x (= 2 2))
   (println x)
   
   (def x (not= 3 2))
   (println x)
   
   (def x (< 2 3))
   (println x)
   
   (def x (<= 2 3))
   (println x)
   
   (def x (> 3 2))
   (println x)
   
   (def x (>= 3 2))
   (println x))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Logical Operators

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def x (or true true))
   (println x)
   
   (def x (and true false))
   (println x)
   
   (def x (not true))
   (println x))
(Example)

Tutorials Point, posted on 6th Dec, 2017

Clojure Bitwise Operators

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def x (bit-and 00111100 00001101))
   (println x)
   
   (def x (bit-or 00111100 00001101))
   (println x)
   
   (def x (bit-xor 00111100 00001101))
   (println x)) 
(Example)

1 2 3 4 5 6 7 ... 18 Next
Advertisements
Loading...