📘 The Brainfuck interpreter written in Perl 6

Create the interpreter for the Brainfuck language. Brainfuck is an esoteric programming language that has a small set of instructions, each of them a single punctuation character. It is assumed that the Brainfuck program has built-in data memory, which is an array of integers, and a pointer to the currently selected item. The two instructions, + … Continue reading “📘 The Brainfuck interpreter written in Perl 6”

📘 Converting Morse to text using Perl 6

Convert the Morse sequence to plain text. To save efforts in typing the decoding table, we can use the %code hash from Task 98, Text to Morse code, and create the ‘inversed’ hash, where the keys are the Morse sequences, and the values are letters or digits: my %char = %code.kv.reverse; Printing this variable shows its contents … Continue reading “📘 Converting Morse to text using Perl 6”

📘 Converting text to Morse code using Perl 6

Convert the given text to the Morse code. Converting text to the Morse code is a relatively easy task. The solution is to replace all the alphanumeric characters with the corresponding representation in the Morse code. In this solution, all the other characters are ignored and are removed from the source string. In the Morse … Continue reading “📘 Converting text to Morse code using Perl 6”

📘 Reading directory content using Perl 6

Print the file names from the current directory. Reading a directory in Perl 6 can be done using the dir routine defined in the IO::Path class. say dir(); This tiny program does not do the task really satisfactory, as the dir routine returns a lazy sequence (an object of the Seq data type) of IO::Path objects. To get the textual … Continue reading “📘 Reading directory content using Perl 6”

📘 The uniq utility written in Perl 6

Create the simple equivalent of the UNIX uniqutility, which only prints the lines from the STDIN input, which are not repeating the previous line. The solution of this task can be built on the solution of Task 95, The catutility. This time, the entered lines have to be saved, so let’s introduce the $previous variable and make an explicit … Continue reading “📘 The uniq utility written in Perl 6”

📘 The cat utility written in Perl 6

Create the equivalent of the UNIX catutility that copies its STDIN input directly to STDOUT. Reading from the input and sending it to the output is a relatively easy task. The $*IN handle is by default connected to STDIN. Being an object of the IO::Handle type, it has the slurp method that returns the whole input text in one … Continue reading “📘 The cat utility written in Perl 6”