How to resolve the algorithm Loops/For step by step in the APL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Loops/For step by step in the APL programming language
Table of Contents
Problem Statement
“For” loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers.
Show how two loops may be nested within each other, with the number of iterations performed by the inner for loop being controlled by the outer for loop. Specifically print out the following pattern by using one for loop nested in another:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Loops/For step by step in the APL programming language
Source code in the apl programming language
stars ← { ⍵ 1 ⍴ {⍵/'*'}¨⍳⍵ }
stars ← { ⍵ 1 ⍴ { {1⌷'*',⍵} ¨ ⍳⍵ } ¨ ⍳⍵ }
∇result ← stars count; i; j; vec
vec ← ⍬
:for i :in ⍳ count
vec ,← ⊂''
:for j :in ⍳ i
vec[i],←'*'
:endfor
:endfor
result ← count 1 ⍴ vec
∇
You may also check:How to resolve the algorithm Simple database step by step in the REXX programming language
You may also check:How to resolve the algorithm Hex words step by step in the APL programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the Tailspin programming language
You may also check:How to resolve the algorithm Tree traversal step by step in the C# programming language
You may also check:How to resolve the algorithm Gray code step by step in the Liberty BASIC programming language