SlideShare ist ein Scribd-Unternehmen logo
1 von 26
 Loops in Lisp
overview Parsing loop clauses Loop syntax Loop constructs Iteration control Conditional and unconditional execution Data types
A loop is a series of expressions that are executed one or more times, a process known as iteration. The driving element of the loop facility is the loop macro. The expanded form consists of three basic parts in the tag body: ,[object Object]
Loop body contains those forms that are executed during iteration.
Stepping is the process of assigning the variable the next item in the series of items.
Loop epilogue contains forms that are executed after iteration terminates.,[object Object]
Order of execution Clauses are executed in the loop body in the order they appear in the source Execution is repeated until a clause terminates a loop or until the CL return, go or throw form is encountered. All variables are initialized first regardless of where the establishing clauses appear in the source The code for any initially clauses is collected into one progn in the order in which the clauses appear in the source. The code for any finally clauses is collected into one progn in the order in which the clauses appear in the source.
A with clause introduces variable binding and an optional initial value. Iteration control clauses implicitly perform the following actions: ,[object Object]
Stepping variables, generally between each execution of the loop body.
Performing termination tests, generally just before the execution of the loop body.,[object Object]
The with construct is similar to a single let construct.
The repeat construct causes the iteration to terminate after a specified number of times.,[object Object]
Append construct takes one form in its clause and appends the value of that form to the end of a list of values
The sum construct takes one form in its clause that must evaluate to a number and adds that number into a running total.
The count construct takes one form in its clause and counts the number of times that form evaluates to a non-nil value.
The minimize construct takes one form In clause and determines the minimum value obtained by evaluating the form.
The maximizeconstruct takes one form In clause and determines the maximum value obtained by evaluating the form.,[object Object]
The always construct takes one form and terminates the loop if the form ever evaluates to nil. The never construct takes one form and terminates the loop if the form ever evaluates to non-nill The thereis construct takes one form and terminates the loop if the form ever evaluates to a non-nill. Unconditional execution: The do construct simply evaluates all forms in its clause. The return construct takes one form and returns its value.
Conditional execution: If construct one form as a predicate and a clause that is executed when the predicate is true. The when construct is a synonym for fi. The else construct provides an optional component of if, when and unless clauses that is executed when the prediction is false. The end construct provides an optional component to mark the end of a conditional clause.
Miscellaneous operations The named construct assigns a name to a loop construct. The initially construct causes its forms to be evaluated in the loop prologue, which proceeds all loop code except for initial settings specified by the constructs with, for, or as. The finally construct causes its forms to be evaluated in the loop epilogue after normal iteration terminates.
Loop syntax A loop consists of following type of clauses: Initial-final ::=initially|finally Variables ::=with|initial-final|for-as|repeat Main ::=unconditional|accumulation |conditional|termination|initial-final Loop ::=(loop [named name] {variables}* {main}* )
(loop {tag|expr}* ) Where expr is any CL expression that can be evaluated , and tag  is any symbol not identifiable as a loop keyword. (loop do {tag|expr}*) A loop prologue consists of any automatic variable initializations prescribed by the variable clauses, along with any initially clauses in the order they appear in the source.
Examples for loops: ;;; To print some numbers (loop as i from 1 to 4          do (print i)) 1      2     3     4 NIL ;;; To print every third number (loop for i from 10 downto 1 by 3              do (print i)) 10       7       4       1  NIL
;;; step incrementally from the default starting value (loop as i below 5               do (print i)) 0     1     2     3     4    NIL
;;; to print every other item in a list. (loop for item in ‘(1 2 3 4 5) bt #’ cddr                do (print item)) 1    3    5  NIL ;;; collect successive tails of a list (loop for sublist on ‘(a b c d)           collect sublist) ,[object Object],[object Object]
End-test control The loop keywords always, never, thereis, until, and while designate constructs that use a single test condition to determine when loop loop iteration should terminate. while expr while construct allows iteration to continue until the specified expression expr evaluates to nil. until expr until construct is equivalent to while, if the value of the specified expression is non-nil, iteration terminates. always expralways takes one form and terminates the loop if the form ever evaluates to nil.

Weitere ähnliche Inhalte

Was ist angesagt? (18)

Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
Loops
LoopsLoops
Loops
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
C# Loops
C# LoopsC# Loops
C# Loops
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
Decision making and looping
Decision making and loopingDecision making and looping
Decision making and looping
 
Loops in C
Loops in CLoops in C
Loops in C
 
Template classes and ROS messages
Template classes and ROS messagesTemplate classes and ROS messages
Template classes and ROS messages
 
Looping (Computer programming and utilization)
Looping (Computer programming and utilization)Looping (Computer programming and utilization)
Looping (Computer programming and utilization)
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
 
C# loops
C# loopsC# loops
C# loops
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
 

Andere mochten auch (20)

MS SQL SERVER: Microsoft sequence clustering and association rules
MS SQL SERVER: Microsoft sequence clustering and association rulesMS SQL SERVER: Microsoft sequence clustering and association rules
MS SQL SERVER: Microsoft sequence clustering and association rules
 
Miedo Jajjjajajja
Miedo JajjjajajjaMiedo Jajjjajajja
Miedo Jajjjajajja
 
RapidMiner: Nested Subprocesses
RapidMiner:   Nested SubprocessesRapidMiner:   Nested Subprocesses
RapidMiner: Nested Subprocesses
 
R Datatypes
R DatatypesR Datatypes
R Datatypes
 
Anime
AnimeAnime
Anime
 
Excel Datamining Addin Intermediate
Excel Datamining Addin IntermediateExcel Datamining Addin Intermediate
Excel Datamining Addin Intermediate
 
Control Statements in Matlab
Control Statements in  MatlabControl Statements in  Matlab
Control Statements in Matlab
 
Huidige status van de testtaal TTCN-3
Huidige status van de testtaal TTCN-3Huidige status van de testtaal TTCN-3
Huidige status van de testtaal TTCN-3
 
Oratoria E RetóRica Latinas
Oratoria E RetóRica LatinasOratoria E RetóRica Latinas
Oratoria E RetóRica Latinas
 
Bind How To
Bind How ToBind How To
Bind How To
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
 
Data Applied:Outliers
Data Applied:OutliersData Applied:Outliers
Data Applied:Outliers
 
Simulation
SimulationSimulation
Simulation
 
C,C++ In Matlab
C,C++ In MatlabC,C++ In Matlab
C,C++ In Matlab
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In Lisp
 
MED dra Coding -MSSO
MED dra Coding -MSSOMED dra Coding -MSSO
MED dra Coding -MSSO
 
SPSS: File Managment
SPSS: File ManagmentSPSS: File Managment
SPSS: File Managment
 
R Statistics
R StatisticsR Statistics
R Statistics
 
Quick Look At Clustering
Quick Look At ClusteringQuick Look At Clustering
Quick Look At Clustering
 
HistoriografíA Latina LatíN Ii
HistoriografíA Latina LatíN IiHistoriografíA Latina LatíN Ii
HistoriografíA Latina LatíN Ii
 

Ähnlich wie Loops in Lisp: An Overview of Loop Syntax and Constructs

Looping statements
Looping statementsLooping statements
Looping statementsJaya Kumari
 
LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In LispLISP Content
 
Control structures ii
Control structures ii Control structures ii
Control structures ii Ahmad Idrees
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsEng Teong Cheah
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & ApplicationsEmroz Sardar
 
C# language basics (Visual Studio)
C# language basics (Visual Studio) C# language basics (Visual Studio)
C# language basics (Visual Studio) rnkhan
 
C# language basics (Visual studio)
C# language basics (Visual studio)C# language basics (Visual studio)
C# language basics (Visual studio)rnkhan
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)Jyoti Bhardwaj
 
Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingNeeru Mittal
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executionseShikshak
 

Ähnlich wie Loops in Lisp: An Overview of Loop Syntax and Constructs (20)

Looping statements
Looping statementsLooping statements
Looping statements
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
LISP:Control Structures In Lisp
LISP:Control Structures In LispLISP:Control Structures In Lisp
LISP:Control Structures In Lisp
 
LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In Lisp
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
 
Loops
LoopsLoops
Loops
 
Iteration
IterationIteration
Iteration
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
06 Loops
06 Loops06 Loops
06 Loops
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
C# language basics (Visual Studio)
C# language basics (Visual Studio) C# language basics (Visual Studio)
C# language basics (Visual Studio)
 
C# language basics (Visual studio)
C# language basics (Visual studio)C# language basics (Visual studio)
C# language basics (Visual studio)
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
Vb script final pari
Vb script final pariVb script final pari
Vb script final pari
 
Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop working
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops_in_Rv1.2b
Loops_in_Rv1.2bLoops_in_Rv1.2b
Loops_in_Rv1.2b
 
Loops in c
Loops in cLoops in c
Loops in c
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 

Mehr von DataminingTools Inc

AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceDataminingTools Inc
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web miningDataminingTools Inc
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataDataminingTools Inc
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsDataminingTools Inc
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisDataminingTools Inc
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technologyDataminingTools Inc
 

Mehr von DataminingTools Inc (20)

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
 

Kürzlich hochgeladen

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Kürzlich hochgeladen (20)

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Loops in Lisp: An Overview of Loop Syntax and Constructs

  • 1. Loops in Lisp
  • 2. overview Parsing loop clauses Loop syntax Loop constructs Iteration control Conditional and unconditional execution Data types
  • 3.
  • 4. Loop body contains those forms that are executed during iteration.
  • 5. Stepping is the process of assigning the variable the next item in the series of items.
  • 6.
  • 7. Order of execution Clauses are executed in the loop body in the order they appear in the source Execution is repeated until a clause terminates a loop or until the CL return, go or throw form is encountered. All variables are initialized first regardless of where the establishing clauses appear in the source The code for any initially clauses is collected into one progn in the order in which the clauses appear in the source. The code for any finally clauses is collected into one progn in the order in which the clauses appear in the source.
  • 8.
  • 9. Stepping variables, generally between each execution of the loop body.
  • 10.
  • 11. The with construct is similar to a single let construct.
  • 12.
  • 13. Append construct takes one form in its clause and appends the value of that form to the end of a list of values
  • 14. The sum construct takes one form in its clause that must evaluate to a number and adds that number into a running total.
  • 15. The count construct takes one form in its clause and counts the number of times that form evaluates to a non-nil value.
  • 16. The minimize construct takes one form In clause and determines the minimum value obtained by evaluating the form.
  • 17.
  • 18. The always construct takes one form and terminates the loop if the form ever evaluates to nil. The never construct takes one form and terminates the loop if the form ever evaluates to non-nill The thereis construct takes one form and terminates the loop if the form ever evaluates to a non-nill. Unconditional execution: The do construct simply evaluates all forms in its clause. The return construct takes one form and returns its value.
  • 19. Conditional execution: If construct one form as a predicate and a clause that is executed when the predicate is true. The when construct is a synonym for fi. The else construct provides an optional component of if, when and unless clauses that is executed when the prediction is false. The end construct provides an optional component to mark the end of a conditional clause.
  • 20. Miscellaneous operations The named construct assigns a name to a loop construct. The initially construct causes its forms to be evaluated in the loop prologue, which proceeds all loop code except for initial settings specified by the constructs with, for, or as. The finally construct causes its forms to be evaluated in the loop epilogue after normal iteration terminates.
  • 21. Loop syntax A loop consists of following type of clauses: Initial-final ::=initially|finally Variables ::=with|initial-final|for-as|repeat Main ::=unconditional|accumulation |conditional|termination|initial-final Loop ::=(loop [named name] {variables}* {main}* )
  • 22. (loop {tag|expr}* ) Where expr is any CL expression that can be evaluated , and tag is any symbol not identifiable as a loop keyword. (loop do {tag|expr}*) A loop prologue consists of any automatic variable initializations prescribed by the variable clauses, along with any initially clauses in the order they appear in the source.
  • 23. Examples for loops: ;;; To print some numbers (loop as i from 1 to 4 do (print i)) 1 2 3 4 NIL ;;; To print every third number (loop for i from 10 downto 1 by 3 do (print i)) 10 7 4 1 NIL
  • 24. ;;; step incrementally from the default starting value (loop as i below 5 do (print i)) 0 1 2 3 4 NIL
  • 25.
  • 26. End-test control The loop keywords always, never, thereis, until, and while designate constructs that use a single test condition to determine when loop loop iteration should terminate. while expr while construct allows iteration to continue until the specified expression expr evaluates to nil. until expr until construct is equivalent to while, if the value of the specified expression is non-nil, iteration terminates. always expralways takes one form and terminates the loop if the form ever evaluates to nil.
  • 27. Never expr never form takes one form and terminates the loop if the form ever evaluates to non-nill. thereis expr thereis construct takes one form and terminates the loop if the form ever evaluates to a non-nil. While and until constructs causes termination, control is passed to the loop epilogue, where any finally clauses will be executed.
  • 28. Ex: (loop for i from 0 to 10 always ( < i 11)) T (loop for i from 0 to 10 never (> i 11)) T (loop for i from 0 to 10 always ( < i 9) finally (print “you won’t see this”))NIL (loop never t finally (print “you won’t see this”))NIL
  • 29. (loop thereis “Here is my value” finally (print “you won’t see this”)) “here is my value” (loop for i from 0 to 10 thereis (when (> i 10) i) ) 11 (loop for i from 1 to 10 thereis (> i 11) finally (print i)) 11 NIL
  • 30.
  • 31. return expr return construct terminates the loop and returns the value of the specified expression as the value of the loop . Ex: (loop for item in ‘( 1 2 3 a 4 5) when (not (numberp item)) return (cerror “enter new value” “non-numeric value: ~s” item))  Error: non-numeric value: A
  • 32. Data types type-spec argument that allows you to specify certain data types for loop variables. The type-spec argument syntax: type-spec ::=of-type d-type-spec d-type-spec ::=type-specifier|(d-type-spec . D-type-spec) The type-spec argument is used for destructing
  • 33. Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net