Loop Construct in LISP Last Updated : 22 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 loopcondition is used to specify the condition so that the loop stops iteratingreturn statement is used to return the results Example: LISP Program to iterate over elements Lisp ;define a variable and set to 1 (setq var 1) ;start the loop (loop ;increment value by 2 each time ;till value is less than 30 (setq var (+ var 2)) ;display (write var) (terpri) ;condition for value is less than 30 (when (> var 30) (return var)) ) Output: 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 Example 2: Lisp ;define a variable and set to 100 (setq var 100) ;start the loop (loop ;decrement value by 10 each time ;till value is less than 30 (setq var (- var 10)) ;display (write var) (terpri) ;condition for value is less than 30 (when (< var 30) (return var)) ) Output: 90 80 70 60 50 40 30 20 Comment More infoAdvertise with us Next Article Loop Construct in LISP S saisravanprojects Follow Improve Article Tags : LISP LISP-Functions Similar Reads 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 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 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 Case Construct in LISP In this article, we will discuss the case construct in LISP. This is used to check multiple test conditions at a time, unlike cond, if and when it allows multiple conditions. Syntax: (case (key_value) ((key1) (statement 1 .............. statement n) ) ((key2) (statement 1 .............. statement n) 2 min read Dolist Construct in LISP 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 2 min read Like