Dolist Construct in LISP Last Updated : 21 Oct, 2021 Comments Improve Suggest changes Like Article Like Report DoList in Common LISP is a looping statement used to iterate the elements in a list. Syntax: (dolist input_list) statements... ) Here, The input_list contains the list of elements that are iterated.The statements are present in the loop. Example 1: LISP Program to iterate the list of elements from 1 to 5. Lisp ;create a dolist of 1 to 5 elements in a list (dolist (n '(1 2 3 4 5 )) ;iterate elements (format t "~% List of elements: ~d " n) ) Output: List of elements: 1 List of elements: 2 List of elements: 3 List of elements: 4 List of elements: 5 Example 2: LISP Program to find the square of each element by iteration. Lisp ;create a dolist of 1 to 5 elements in a list (dolist (n '(1 2 3 4 5 )) ;iterate elements to print each element (format t "~% Element's value: ~d " n) ;iterate elements to find square of each element (format t "~% Square of element: ~d " (* n n)) (terpri) ) Output: Element's value: 1 Square of element: 1 Element's value: 2 Square of element: 4 Element's value: 3 Square of element: 9 Element's value: 4 Square of element: 16 Element's value: 5 Square of element: 25 Comment More infoAdvertise with us Next Article Loop For Construct in LISP G gottumukkalabobby Follow Improve Article Tags : LISP LISP-Control-Structures Similar Reads Do Construct in LISP In this article, we will discuss the Do Construct in LISP. Do construct is used to perform an iteration in a structured format. Syntax: (do ((variable1 value1 new updated value 1) (variable2 value2 new updated value 2) ------------------------------- ------------------------------- (variable n value 2 min read Dotimes Construct in LISP In this article, we will discuss the dotimes loop in LISP. The dotimes is a looping statement used to iterate the elements. Â Unlike other looping constructs, it only loops for a specified number of iterations. Syntax: (dotimes (n range) statements --------------- -------------- ) where, n is the sta 1 min read If Construct in LISP In this article, we will discuss the if construct in LISP. The if is a decision-making statement used to check whether the condition is right or wrong. The if the condition is right, then it will go inside the if block and execute the statements under if block. Otherwise, the statements are not exec 2 min read Loop For Construct in LISP The loop for construct in common LISP is used to iterate over an iterable, similar to the for loop in other programming languages. It can be used for the following: This is used to set up variables for iteration.It can be used for conditionally terminate the iteration.It can be used for operating on 2 min read Loop Construct in LISP In this article, we will discuss Loop Construct. This Construct is used to iterate the data until it finds the return statement. And then it will stop iterating and return the results. Syntax: (loop (statements) condition return ) where, loop is the keywordstatements are used to iterate the loopcond 2 min read Cond Construct in LISP In this article, we will discuss cond construct in LISP. The cond is a decision-making statement used to make n number of test conditions. It will check all the conditions. Syntax: (cond (condition1 statements) (condition2 statements) (condition3 statements) ... (conditionn statements) ) Here, The c 2 min read Like