How to resolve the algorithm Execute HQ9+ step by step in the 11l programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Execute HQ9+ step by step in the 11l programming language

Table of Contents

Problem Statement

Implement a   HQ9+   interpreter or compiler.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Execute HQ9+ step by step in the 11l programming language

Source code in the 11l programming language

F hello()
   print(‘Hello, world!’)

String src
F quine()
   print(:src)

F bottles()
   L(i) (99.<2).step(-1)
      print(‘#. bottles of beer on the wall’.format(i))
      print(‘#. bottles of beer’.format(i))
      print(‘Take one down, pass it around’)
      print(‘#. bottles of beer on the wall’.format(i - 1))
      print()

   print(‘2 bottles of beer on the wall’)
   print(‘2 bottles of beer’)
   print(‘Take one down, pass it around’)
   print(‘1 bottle of beer on the wall’)
   print()

   print(‘1 bottle of beer on the wall’)
   print(‘1 bottle of beer’)
   print(‘Take one down, pass it around’)
   print(‘No more bottles of beer on the wall’)
   print()

   print(‘No more bottles of beer on the wall’)
   print(‘No more bottles of beer on the wall’)
   print(‘Go to the store and buy some more’)
   print(‘99 bottles of beer on the wall.’)
   print()

V acc = 0
F incr()
   :acc++

:start:
src = File(:argv[1]).read()

[Char = (() -> N)] dispatch
dispatch[Char(‘h’)] = hello
dispatch[Char(‘q’)] = quine
dispatch[Char(‘9’)] = bottles
dispatch[Char(‘+’)] = incr

L(i) src.lowercase()
   I i C dispatch
      dispatch[i]()

  

You may also check:How to resolve the algorithm Factorial step by step in the Peylang programming language
You may also check:How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Wren programming language
You may also check:How to resolve the algorithm Comma quibbling step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Map range step by step in the Vala programming language
You may also check:How to resolve the algorithm Euler method step by step in the VBA programming language