How to resolve the algorithm Loops/Break step by step in the Lasso programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Loops/Break step by step in the Lasso programming language
Table of Contents
Problem Statement
Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive).
If a number is 10, stop the loop after printing it, and do not generate any further numbers.
Otherwise, generate and print a second random number before restarting the loop.
If the number 10 is never generated as the first number in a loop, loop forever.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Loops/Break step by step in the Lasso programming language
Source code in the lasso programming language
local(x = 0)
while(#x != 10) => {^
#x = integer_random(19,0)
#x
#x == 10 ? loop_abort
', '+integer_random(19,0)+'\r'
^}
You may also check:How to resolve the algorithm Integer sequence step by step in the Fantom programming language
You may also check:How to resolve the algorithm Perfect shuffle step by step in the Picat programming language
You may also check:How to resolve the algorithm DNS query step by step in the Java programming language
You may also check:How to resolve the algorithm Catamorphism step by step in the Maxima programming language
You may also check:How to resolve the algorithm Yin and yang step by step in the Asymptote programming language