1) What is Clojure?
Clojure is a dynamic, general-purpose programming language. It is simple, coherent and powerful tool. It is based on Lisp Programming language.
2) Which platform is used to run Clojure?
JVM (Java Virtual Machine), CLR (Common Language Runtime) and JavaScript are platform used to run Clojure.
3) Who designed the Clojure?
Rich Hickey designed the Clojure.
4) What is the stable version of Clojure?
The stable version of Clojure is
1.8 and released on 19 January 2016.
5) How to write a simple program of Clojure?
The following code for write a simple program:
(ns clojure.examples.hello
(:gen-class))
(defn hello-world [username]
(println (format "Hello, %s" username)))
(hello-world "world")
6) What are the features of Clojure?
There are various following features of Clojure:
- It is based on the Lisp programming Language.
- It is functional programming language.
- It manages the state of an application.
- It supports concurrency.
7) What is the use of StructMaps?
StructMaps are used to create structures.
8) What is the filename extension of Clojure?
Clojure filename extension are:
clj, .cljs, .cljc, .edn
9) What is the keyword to define a function?
The
‘defn’ keyword is used to define the function.
10) What is REPL in Clojure?
REPL stand for
read eval print loop. It is a tool for Clojure code.
11) How to launch a REPL?
The following command is used to launch a REPL:
java -cp clojure.jar clojure.main
12) What are the Clojure variables?
There are following Clojure variables:
- Short
- Int
- Long
- Float
- Char
- Boolean
- String
13) How to declare a variable in Clojure?
The following code for declare a variable in Clojure:
14) What are the operators in Clojure?
Clojure has following operators that are given below:
- Arithmetic operators
- Relational operators
- Logical operators
- Bitwise operators
15) What is the syntax for declaration the operator and operands in Clojure?
In Clojure, the following syntax for declaring the operator and operand is:
(operator operand1 operand2 operandn)
16) What is clojure.main namespace in Clojure?
Clojure.main namespace provides functions that allow Clojure program and interactive sessions.
17) What are the properties of Socket Server?
The following socket Server properties are:
Socket Server Properties |
Description |
server-daemon |
It is by defaults true and socket server thread doesn’t block exit. |
Address |
It hosts or address, It is by defaults to loopback. |
Port |
It uses positive integer, it is required. |
Accept |
It is namespaced symbol of function. It is used to invoke on socket accept, it is required. |
Args |
It is sequential collection of args to pass to accept. |
bind-err |
It is by default true, and binds *err* to socket out stream. |
client-daemon |
It is by default true and socket client thread doesn’t block exit. |
18) What is set in Clojure?
In Clojure,
set is unique value that is created with the help of the set command.
Example:
(ns clojure.examples.example
(:gen-class))
(defn example []
(println (set '(1 1 2 2))))
(example)
19) What is the use of Macros in Clojure?
Macro is used to define the syntactic constructs which would require primitives or built-in support in other languages.
20) What is Map in Clojure?
Map is a collection, which is used to maps the Keys to the values. It provided two types of Map:
21) What is Clojure Namespace?
Clojure Namespace is used to specify the classes into separate logical spaces.
22) What are the special variables?
There are following two types of special variables:
- &form : The actual form (as data) that is being invoked
- &env : A map of local bindings. It is from symbols that is used to objects holding and compiler information about the binding.
23) What is the use of Clojure libs?
A lib is a named unit of Clojure source code. It contained in a java resource within classpath. Closer provides code loading and dependency tracking via lib.
Example:
(ns com.my-company.clojure.examples.my-utils
(:import java.util.Date)
(:use [clojure.string :only (join)])
(:require [clojure.java.io :as jio]))
24) What is Atoms in Clojure?
In Clojure, atom is a data type that provides a way to manage shared synchronous, independent state.
Example:
(ns clojure.examples.example
(:gen-class))
(defn example []
(def myatom (atom 1))
(println @myatom))
(example)