Solving The Programming Language Design Essay

2310 Words Nov 28th, 2016 10 Pages
Overview:
Iterative statement is the programming language design feature that is going to be discussed. And the programming languages for which the feature is discussed are C, Perl, Prolog and Common Lisp.
In C the three pre-defined iterative statements are for, while and do while.
In Perl the pre-defined iterative statements include for, foreach, while, do while and until.
In Common Lisp the pre-defined iterative statements include do, dotimes, dolist and loop (includes for and while)
In Prolog there are no iterative statements. Since Prolog is a fact and rule based language and the programmers are allowed to provide with the info what needs to be achieved rather than how it needs to be achieved there are no iterative statements in Prolog. But iteration can be achieved in Prolog using recursion. Recursion in Prolog can be achieved using the same rule within itself.
• In for loop and while loop, statements are executed after condition check form the first iteration.
• In do while loop statements are executed without any condition check for first iteration and are executed only if the condition is true for the successive iterations.
• until is used to iterate statements until a particular expression or condition is evaluated to true.
• foreach and dolist are used to iterate statements over an array or a list. Both the loops can have a variable whose value represents an element of the list for each iteration.
• dotimes is similar to dolist but instead of iterating over the…

Related Documents