Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:getting_started:lisp_crash_course [2022/05/03 20:43] khoshnamdoc:getting_started:lisp_crash_course [2022/05/17 09:01] khoshnam
Line 940: Line 940:
  
 <code lisp> <code lisp>
-CL-USER>(defun *number-was-odd nil)+CL-USER>(defun *number-was-oddnil)
  
 CL-USER>(if (oddp 5) CL-USER>(if (oddp 5)
- (progn (setf (number-was-odd t)+ (progn (setf (*number-was-oddt)
  ‘odd-number)  ‘odd-number)
  ‘even-number)  ‘even-number)
Line 983: Line 983:
 </code> </code>
  
-<code lisp>+
  
 **defparameter** **defparameter**
 \\ \\
 +<code lisp>
 CL-USER>(defparameter *fruit* 'apple) CL-USER>(defparameter *fruit* 'apple)
 CL-USER>(cond ((eq *fruit* 'apple) 'its-an-apple) CL-USER>(cond ((eq *fruit* 'apple) 'its-an-apple)
Line 1061: Line 1062:
      body-form*)      body-form*)
 </code> </code>
 +The list-form will be the list of elements that are iterated\\
 +The body-form are present in the loop
  
 <code lisp> <code lisp>
Line 1072: Line 1075:
 **Dotimes** **Dotimes**
 \\ \\
-With dotimes you can do looping for some fixed number of iterations.+With dotimes you can do looping for some fixed number of iterations. So the dotimes is quite similar to dolist, but you should consider that it loops for a particular number of times.
  
 <code lisp> <code lisp>
Line 1092: Line 1095:
 \\ \\
 Do is more general than two others.  Do is more general than two others. 
 +
 +<code lisp>
 +CL-USER>(do (var-form*)
 +               (end-form*)
 +                body-form*)
 +</code>
 +Var-form consists of some varibles that we defined and their initial values And how each iteration will affect it\\
 +end-form composed of how the loop finish and value returned. It will evaluated at the start of the iteration.
  
 <code lisp> <code lisp>