Intro to Clojure (L15) Flashcards

1
Q

Clojure is designed as a modern dialect of what other language?

A

LISP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Clojure is implemented on top of what virtual machine?

A

The Java Virtual Machine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Does Clojure have direct support for concurrency?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Clojure expressions are written in parenthesis, and are also called?

A

Forms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In Clojure, basic math operations use infix notation.

A

False, they use prefix notation (as all Clojure functions do).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Clojure forms may be void, in that they return nothing.

A

False, Clojure expressions always return something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the name of Clojure’s command line interface, and what does it stand for?

A

REPL stands for READ-EVAL-PRINT-LOOP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What character is used to comment in Clojure?

A

The semi colon (;).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What value is returned by Clojure’s print & println forms?

A

nil

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are Clojure’s 5 primitive types?

A

Integer, float, string, boolean, and nil.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Types are explicitly defined in Clojure.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Are Clojure’s boolean literals written in capitalized form, or all lowercase?

A

All lowercase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Are strings enclosed by single or double quotes in Clojure?

A

Double.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Labels associated to values using the “def” function can be reassigned later.

A

They can be, but aren’t meant to be changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Does the label, or the value come first following a call to “def”?

A

Label, then value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between fn and defn in Clojure?

A

fn defines an anonymous function that may then be labelled using def. defn combines def and fn into one operation.

17
Q

How are values returned by functions in Clojure?

A

The value to be returned must be the final form in the function body.

18
Q

When using REPL, what will the following line output?
(fn [] “hello world”)

A

A representation of the function object.

19
Q

When using REPL, what will the following line output?
((fn [] “hello world”))

A

hello world

20
Q

Clojure’s if-form takes 2 other forms - a then-form and an else-form.

A

False, it must first take a boolean-form.

21
Q

Clojure’s else-form in an if-form is optional.

22
Q

If the 3rd else-form is omitted from an “if” form, what is returned if the boolean-form evaluates to false?

23
Q

What type of form can be used to group multiple “then” (or “else”) statements into a single expression?

A

the “do” form.

24
Q

Which expression in a “do” form is returned by that do form?

A

The last expression.

25
What form combines the "if" and "do" forms?
The "when" form.
26
The "when" form can also optionally accept an else-form.
False, it cannot accept an else-form at all.
27
"When" forms always return nil when their conditions are false.
True.
28
What are Clojure's falsey values?
nil and false.
29
What are Clojure's truthy values?
Everything besides nil and false.