0% found this document useful (0 votes)
19 views20 pages

Common Clojure Expression Flashcards

Uploaded by

Felipe Caetano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views20 pages

Common Clojure Expression Flashcards

Uploaded by

Felipe Caetano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

defn let

= is

if fn

def str

deftest map
Bind names in a local scope. Define a function at the top level.

Assert that an expression returns truthy inside of a Return true if all arguments are equal, false
test. otherwise.

Create a function. Two-way conditional branch.

Convert the arguments to strings and concatenate


Define a top level Var.
them.

Create a seq whose elements are the result of


Define a test.
applying a function to the elements of another seq.
ns ->

defn- first

when testing

or apply

assoc count
Thread-first macro. Define a namespace at the top of a file.

Define a function at the top level that is private to


Return the initial element of a seq.
the namespace.

Add context text to enclosed assertions. One-way conditional branch.

Evaluate expressions in turn, returning the first that


Call a function on a seq of arguments.
is truthy or nil otherwise.

Return the number of elements in the given Add one or more key/value pairs to an associative
collection. data structure such as a hashmap or vector.
and not

nil? defmethod

+ defmacro

get *

cond recur
Evaluate expressions in turn, returning the first that
Return true if the argument is falsey, false otherwise.
is not truthy, or the last one otherwise.

Define a method in a multimethod. Return true if the argument is nil, false otherwise.

Define a new macro. Add all arguments numerically.

Return the value associated with the key in an


Multiply all arguments numerically.
associative data structure.

Explicit tail recursion. Multi-way conditional branch.


println do

seq doseq

->> throw

atom reduce

- name
Execute all expressions and return the value of the
Print out all arguments and output a new line.
last expression.

Iterate over a seq, executing the body expressions for


Convert a value to a seq or nil if it’s empty.
each element.

Raise an exception. Thread last macro.

Starting with an initial value, apply a function to


Create a Atom.
that value and successive elements of a seq.

Return the non-namespace part of a keyword or


Subtract arguments numerically, or negate a number.
symbol as a string, or the argument itself if it’s a
string.
instance? conj

if-let inc

swap! into

range filter

get-in merge
Add an element to a collection. Check if a value is an instance of a class or interface.

Two-way conditional branch with binding of the test


Add one to a number.
result.

Replace an Atom’s value with the result of applying a


Add elements of a seq to a collection.
function to the current value.

Keep elements of a seq that are truthy for a given


Create a seq of numbers from start to end.
predicate.

Get the value from a nested associative data


Add key/value pairs from one map into another.
structure at a path.
empty? loop

for try

list format

catch when-not

rest <
Returns true if there are no elements in a collection,
Create a scope for tail recursion.
false otherwise.

Create a point for catching exception. List comprehension.

Create a string using java.lang.String.format. Create a list.

Declare what to do when a particular class of


Negative one-way conditional branch.
exception is caught.

Return a seq of elements from a collection excluding


Mathematical less than.
the first.
vec partial

concat reset!

set when-let

/ int

cons nth
Take a function and arguments and make a new
Convert a collection to a vector.
function that has those arguments already applied.

Set the value of an Atom without regard to the


String seqs together in order.
current value.

One-way conditional branch with binding of the test


Convert a collection to a set.
result.

Convert a number to an integer. Numeric division.

Retrieve an element from a seq by numeric index. Add an element to the beginning of a seq.
assert defproject

second are

contains? update-in

> doto

defprotocol .
Define a Leiningen project. Throw an AssertionError if expression is false.

Assert that multiple expressions are truthy in a test. Return the second element of a seq.

Modify a value at a path in a nested data structure


Does a key appear in an associative data structure?
by applying a function to that value.

Execute forms on first argument, then return it. Mathematical greater than.

Execute a Java method. Define a new protocol.


meta ==

keys next

map? string?

set! aget

keyword if-not
Numeric equality comparison (type-independent). Return the metadata on a value.

Return a seq of elements from a collection excluding


Return a seq of keys from a hash map.
the first, or nil if it’s empty.

Return true if the argument is a string, false Return true if the argument is a map, false otherwise.
otherwise.

Set thread-local vars, Java object instance fields, and


Return the value of an array at an index.
Java class static fields.

Create a keyword from a string or a namespace and


Two-way negative conditional branch.
name.
symbol binding

dec dissoc

defrecord comp

not= thrown?

float select
Create a symbol from a string or a namespace and
Create thread-local bindings for dynamic vars.
name.

Remove a key/value from an associative data


Subtract one from a number.
structure.

Compose two or more functions. Create a new record type.

A special form in clojure.test/is expressions to check Return true if the arguments are not equal, false
if an exception is thrown. otherwise.

Return a new set keeping only elements that are


Convert a number to a Java float.
truthy for a given predicate.

You might also like