Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

clojure
first
community creator
method

What is the first method in Clojure?

Chinweuba Elijah Azubuike

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

What is a list?

A list is a data storage structure that holds a collection of data objects. The list method in Clojure is used to build lists. You can see this shot for more information on creating a list.

The first method in Clojure

The first method is a list method used to fetch the first item of a list.

Syntax

(first lst)

Parameter

One parameter is passed to the first method, where lst in the syntax above represents the list.

Let’s look at an example.

(ns clojure.Test.example
(:gen-class))
(defn Firstt []
(println (first (list 1 2,3))))
(Firstt)
The first method

Explanation

In the code above, we’ll print the first item of a list.

Line 3: We define a function Firstt.

Line 4: We print the return value of the first method using the println. Then, we fetch the first item of the list using the list method first.

Line 5: We call the Firstt function.

RELATED TAGS

clojure
first
community creator
method

CONTRIBUTOR

Chinweuba Elijah Azubuike

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring