How to resolve the algorithm Mutual recursion step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Mutual recursion step by step in the Quackery programming language

Table of Contents

Problem Statement

Two functions are said to be mutually recursive if the first calls the second, and in turn the second calls the first. Write two mutually recursive functions that compute members of the Hofstadter Female and Male sequences defined as:

(If a language does not allow for a solution using mutually recursive functions then state this rather than give a solution by other means).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Mutual recursion step by step in the Quackery programming language

Source code in the quackery programming language

                  forward is f ( n --> n )

  [ dup 0 = if done
    dup 1 - recurse f - ] is m ( n --> n )
   
  [ dup 0 = iff 1+ done
    dup 1 - recurse m - ]
                    resolves f ( n --> n )

  say "f = "
  20 times [ i^ f echo sp ] cr
  say "m = "
  20 times [ i^ m echo sp ] cr

  

You may also check:How to resolve the algorithm Factorial step by step in the Java programming language
You may also check:How to resolve the algorithm GUI/Maximum window dimensions step by step in the Raku programming language
You may also check:How to resolve the algorithm Best shuffle step by step in the Clojure programming language
You may also check:How to resolve the algorithm Compare a list of strings step by step in the XProfan programming language
You may also check:How to resolve the algorithm Literals/Integer step by step in the EMal programming language