How to resolve the algorithm Loops/Nested step by step in the Racket programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Loops/Nested step by step in the Racket programming language
Table of Contents
Problem Statement
Show a nested loop which searches a two-dimensional array filled with random numbers uniformly distributed over
[ 1 , … , 20 ]
{\displaystyle [1,\ldots ,20]}
. The loops iterate rows and columns of the array printing the elements until the value
20
{\displaystyle 20}
is met. Specifically, this task also shows how to break out of nested loops.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Loops/Nested step by step in the Racket programming language
Source code in the racket programming language
#lang racket
(define (scan xss)
(for* ([xs xss]
[x xs]
#:final (= x 20))
(displayln x)))
(define matrix
(for/list ([x 10])
(for/list ([y 10])
(+ (random 20) 1))))
(scan matrix)
You may also check:How to resolve the algorithm Distributed programming step by step in the Oz programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean/Calculate Pi step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Loops/Foreach step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Draw a cuboid step by step in the Ring programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the Pascal programming language