How to resolve the algorithm Repeat step by step in the PureBasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Repeat step by step in the PureBasic programming language

Table of Contents

Problem Statement

Write a procedure which accepts as arguments another procedure and a positive integer. The latter procedure is executed a number of times equal to the accepted integer.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Repeat step by step in the PureBasic programming language

Source code in the purebasic programming language

Prototype.i fun(x.i)

Procedure.i quark(z.i)
  Debug "Quark "+Str(z) : ProcedureReturn z-1
EndProcedure

Procedure rep(q.fun,n.i)
  Repeat : n=q(n) : Until n=0
EndProcedure

rep(@quark(),3)

  

You may also check:How to resolve the algorithm String comparison step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the Nim programming language
You may also check:How to resolve the algorithm Ackermann function step by step in the Rust programming language
You may also check:How to resolve the algorithm Read a specific line from a file step by step in the Clojure programming language
You may also check:How to resolve the algorithm Calendar step by step in the Befunge programming language