Examples collection
Welcome to the examples collection of the Raku programming language!
Categories
Best of Rosettacode
The best of the rosettacode.org examples
- 100 Doors 100-doors.pl
- 24 game 24-game.pl
- Accumulator factory accumulator-factory.pl
- Ackermann function ackermann-function.pl
- Arbitrary-precision integers (included) arbitrary-precision-integers.pl
- Balanced brackets balanced-brackets.pl
- Binomial Coefficient binomial-coefficient.pl
- Copy a string copy-a-string.pl
- Create a two-dimensional array at runtime create-a-two-dimensional-array-at-runtime.pl
- Hailstone sequence hailstone-sequence.pl
- Last fridays of the year last-fridays-of-year.pl
- Prime decomposition prime-decomposition.pl
- README.md
99 Problems
Based on lisp 99 problems
- P01 - Find the last box of a list. P01-scottp.pl
- P01 - Find the last element of a list. P01-topo.pl
- P02 - Find the last but one box of a list. P02-scottp.pl
- P02 - Find the last two elements of a list. P02-topo.pl
- P03 - Find the K'th element of a list. P03-scottp.pl
- P03 - Find the kth element of a list. P03-topo.pl
- P04 - Find the number of elements of a list P04-scottp.pl
- P04 - Find the number of elements in a list. P04-topo.pl
- P05 - Reverse a list P05-scottp.pl
- P05 - Reverse a list. P05-topo.pl
- P06 - Find out whether a list is a palindrome. P06-ajs.pl
- P06 - Find out whether a list is a palindrome. P06-scottp.pl
- P06 - Find out whether a list is a palindrome. P06-topo.pl
- P07 - Flatten a nested array structure. P07-eric256.pl
- P07 - Flatten a nested array structure. P07-topo.pl
- P07 - Flatten a nested array structure. P07-viklund.pl
- P08 - Eliminate consecutive duplicates of list elements. P08-eric256.pl
- P08 - Eliminate consecutive duplicates of list elements. P08-topo.pl
- P08 - Eliminate consecutive duplicates of list elements. P08-viklund.pl
- P09 - Pack consecutive duplicates of list elements into sublists. P09-rje.pl
- P09 - Pack consecutive duplicates of list elements into sublists. P09-scottp.pl
- P09 - Pack consecutive duplicate elements of a list into sublists. P09-topo.pl
- P09 - Pack consecutive duplicates of list elements into sublists. P09-unobe.pl
- P10 - Run-length encoding of a list. P10-scottp.pl
- P10 - Run-length encoding of a list. P10-topo.pl
- P10 - Run-length encoding of a list. P10-unobe.pl
- P11 - Modified run-length encoding. P11-topo.pl
- P11 - Modified run-length encoding. P11-unobe.pl
- P12 - Decode a run-length encoded list. P12-rhebus.pl
- P12 - Decode modified run-length encoding. P12-topo.pl
- P12 - Decode a run-length encoded list. P12-unobe.pl
- P13 - Run-length encoding of a list (direct solution). P13-rhebus.pl
- P13 - Direct run-length encoding. P13-topo.pl
- P13 - Run-length encoding of a list (direct solution). P13-viklund.pl
- P14 - Duplicate the elements of a list. P14-scottp.pl
- P14 - Duplicate the elements in a list. P14-topo.pl
- P14 - Duplicate the elements of a list. P14-viklund.pl
- P15 - Replicate the elements of a list a given number of times. P15-rhebus.pl
- P15 - Replicate the elements of a list a given number of times. P15-topo.pl
- P15 - Replicate the elements of a list a given number of times. P15-unobe.pl
- P16 (**) Drop every N'th element from a list. P16-edpratomo.pl
- P16 - Drop every nth element from a list. P16-topo.pl
- P17 - Split a list into two parts; the length of the first part is given. P17-topo.pl
- P17 - Split a list into two parts; the length of the first part is given. P17-unobe.pl
- P18 - Extract a slice from a list. Indices start at 1. P18-topo.pl
- P19 - Rotate a list n places to the left. P19-topo.pl
- P20 - Remove the K'th element from a list. P20-rhebus.pl
- P20 - Remove the kth element of a list. P20-topo.pl
- P21 - Insert an element at a given position into an array. P21-scottp.pl
- P21 - Insert an element at a given position into a list. P21-topo.pl
- P22 - Create a list containing all integers within a given range. P22-scottp.pl
- P22 - Create a list containing all integers within a given range. P22-topo.pl
- P23 - Extract a given number of randomly selected elements from a list. P23-topo.pl
- P24 - Draw N different random numbers from the set 1..M. P24-topo.pl
- P25 - Generate a random permutation of the elements of a list. P25-topo.pl
- P26 - Generate the combinations of k distinct objects chosen from the n elements of a list. P26-topo.pl
- P31 - Determine whether a given integer number is prime. P31-rhebus.pl
- P32 - Determine the greatest common divisor of two positive integer P32-rhebus.pl
- P33 - Determine whether two positive integer numbers are coprime. P33-rhebus.pl
- P34 - Calculate Euler's totient function phi(m). P34-rhebus.pl
- P35 - Determine the prime factors of a given positive integer. P35-rhebus.pl
- P36 - Determine the prime factors of a given positive integer (2). P36-ovid.pl
- P36 - Determine the prime factors of a given positive integer (2). P36-rhebus.pl
- P37 - Calculate Euler's totient function phi(m) (improved). P37-rhebus.pl
- P39 - A list of prime numbers. P39-rhebus.pl
- P40 - Goldbach's conjecture. P40-rhebus.pl
- P41 - A list of Goldbach compositions. P41-rhebus.pl
- P91 - Knight's tour. P91-edpratomo.pl
- README.md
Cookbook
Cookbook examples
- Perl 6 Cookbook: Introduction to Strings 01strings
- Substrings 01strings
- Swapping values 01strings
- Converting between characters and numbers. 01strings
- Using Named Unicode Chars 01strings
- Reversing a String by Word or Character 01strings
- Upper/Lower Case 01strings
- Trimming whitespace from both ends of a string 01strings
- Soundex Matching 01strings
- Valid Number 02numbers
- Convert to/from Roman Numerals 02numbers
- Logarithms 02numbers
- Complex Numbers 02numbers
- Convert Bases 02numbers
- Today's Date 03dates-and-times
- DateTime to Epoch Seconds 03dates-and-times
- Epoch Seconds to DateTime 03dates-and-times
- Adding and Subtracting Dates 03dates-and-times
- Subtracting Two Dates From Each other 03dates-and-times
- From date to week of year, month of year, day of year 03dates-and-times
- Hi-Res Timings 03dates-and-times
- Specifying a list in your program 04arrays
- Printing a list with commas 04arrays
- Iterating Over an Array 04arrays
- Traversing a hash 05hashes
- Copy and substitute simultaneously 06pattern-matching
- Matching alphabetic wide characters 06pattern-matching
- Opening a file 07file-access
- Count File Lines 08file-contents
- Process every word in a file 08file-contents
- Read file lines backwards 08file-contents
- Get/Set Filetime 09directories
- Delete File 09directories
- Copy/Move File 09directories
- Process all files in a directory 09directories
- Get list of files matching a pattern 09directories
- Process files recursively 09directories
- Splitting up a filename 09directories
- Process files lazy 09directories
- Accessing subroutine arguments 10subroutines
- Constructing an object 13classes-objects-and-ties
- Managing Instance data 13classes-objects-and-ties
- Managing Instance data 13classes-objects-and-ties
- Overloading operators 13classes-objects-and-ties
- Executing SQL with DBIish 14database-access
- Parsing program arguments 15interactivity
- Test whether program is interactive or not 15interactivity
- Clear the screen 15interactivity
- Change text colour 15interactivity
- Timeout Operation 16processes
- List Signals 16processes
- Send a signal to a process 16processes
- Catch ctrl-c 16processes
- Writing a TCP Client 17sockets
- Writing a TCP Server 17sockets
- Writing a CGI Script 19cgi-programming
- Fetch uri 20web-automation
- README.md
Project Euler
Answers for Project Euler
- Multiples of 3 and 5 prob001-cspencer.pl
- Multiples of 3 and 5 prob001-eric256.pl
- Multiples of 3 and 5 prob001-grondilu.pl
- Multiples of 3 and 5 prob001-hexmode.pl
- Multiples of 3 and 5 prob001-unobe.pl
- Even Fibonacci numbers prob002-eric256.pl
- Even Fibonacci numbers prob002-gerdr.pl
- Even Fibonacci numbers prob002-hexmode.pl
- Largest prime factor prob003-eric256.pl
- Largest prime factor prob003-gerdr.pl
- Largest prime factor prob003-hexmode.pl
- Largest prime factor prob003-lanny.pl
- Largest palindrome product prob004-unobe.pl
- Largest palindrome product prob004-xfix.pl
- Smallest multiple prob005-unobe.pl
- Smallest multiple prob005-xfix.pl
- Sum square difference prob006-polettix.pl
- 10001st prime prob007-polettix.pl
- Largest product in a series prob008-duff.pl
- Largest product in a series prob008-duff2.pl
- Special Pythagorean triplet prob009-gerdr-feeds.raku
- Special Pythagorean triplet prob009-gerdr.raku
- Special Pythagorean triplet prob009-polettix.pl
- Summation of primes prob010-polettix.pl
- Largest product in a grid prob011-moritz.pl
- Highly divisible triangular number prob012-polettix.pl
- Large sum prob013-grondilu.pl
- Longest Collatz sequence prob014-felher.pl
- Lattice paths prob015-felher.pl
- Power digit sum prob016-grondilu.pl
- Number letter counts prob017-duff.pl
- Maximum path sum I prob018-felher.pl
- Counting Sundays prob019-grondilu.pl
- Factorial digit sum prob020-grondilu.pl
- Amicable numbers prob021-gerdr.pl
- Names scores prob022-grondilu.pl
- Non-abundant sums prob023-shlomif.pl
- Lexicographic permutations prob024-moritz.pl
- 1000-digit Fibonacci number prob025-polettix.pl
- Reciprocal cycles prob026-shlomif.pl
- Quadratic primes prob027-shlomif.pl
- Number spiral diagonals prob028-shlomif.pl
- Distinct powers prob029-gerdr.pl
- Distinct powers prob029-polettix.pl
- Coin sums prob031-shlomif.pl
- Digit cancelling fractions prob033-andreoss.pl
- Digit factorials prob034-quinny.pl
- Double-base palindromes prob036-xenu.pl
- Pandigital multiples prob038-andreoss.pl
- Integer right triangles prob039-quinny.pl
- Pandigital Prime prob041-heyajulia-alternative.raku
- Pandigital Prime prob041-heyajulia.raku
- Coded triangle numbers prob042-shlomif.p6
- Distinct primes factors prob047-gerdr.pl
- Permuted multiples prob052-duff.pl
- Combinatoric selections prob053-duff.pl
- Combinatoric selections prob053-gerdr.pl
- Poker hands prob054-andreoss.pl
- Lychrel numbers prob055-shlomif.p6
- prob056-shlomif.p6
- XOR decryption prob059-andreoss.pl
- Powerful digit counts prob063-moritz.pl
- Powerful digit counts prob063-polettix.pl
- Convergents of e prob065-andreoss.pl
- prob065-grondilu.pl
- Diophantine equation prob066-andreoss.pl
- Maximum path sum II prob067-felher.pl
- Square root digital expansion prob080-andreoss.pl
- Path sum: two ways prob081-moritz.pl
- Roman numerals prob089-andreoss.pl
- Square digit chains prob092-moritz.pl
- Large non-Mersenne prime prob097-andreoss.pl
- Anagramic squares prob098-andreoss.pl
- Largest exponential prob099-andreoss.pl
- README.md
Games
Games written in Perl 6
- Blackjack blackjack.p6
- Connect4 connect4.p6
- Flashcard flashcard.p6
- Hangman hangman.p6
- Tic Tac Toe tictactoe.p6
- Yahtzee yahtzee.p6
Interpreters
Language or DSL interpreters
- Brainfuck Interpreter brainfuck.p6
- Simple Infix Arithmetic Calculator calc.p6
- Simple Lisp Interpreter lisp.pl
- Reverse Polish Notation Calculator RPN.pl
Module Management
Examples of organising modules
Parsers
Example grammars
Perlmonks
Answers to perlmonks.org questions
Project Rosalind
Bioinformatics-related programming problems
- Counting Disease Carriers afrq-grondilu.pl
- Introduction to Alternative Splicing aspc-grondilu.pl
- Consensus and Profile cons-grondilu.pl
- Comparing Spectra with the Spectral Convolution conv-grondilu.pl
- Creating a Character Table from Genetic Strings cstr-grondilu.pl
- Creating a Character Table ctbl-grondilu.pl
- Introduction to Protein Databases dbpr-grondilu.pl
- Counting DNA Nucleotides dna-gerdr.pl
- Counting DNA Nucleotides dna-grondilu.pl
- Enumerating Unrooted Binary Trees eubt-grondilu.pl
- Expected Number of Restriction Sites eval-grondilu.pl
- Rabbits and Recurrence Relations fib-grondilu.pl
- Mortal Fibonacci Rabbits fibd-grondilu.pl
- Computing GC Content gc-gerdr.pl
- Overlap Graphs grph-grondilu.pl
- Counting Point Mutations hamm-grondilu.pl
- Calculating Expected Offspring iev-grondilu.pl
- Independent Segregation of Chromosomes indc-grondilu.pl
- Mendel's First Law iprb-grondilu.pl
- Finding Disjoint Motifs in a Gene itwv-grondilu.pl
- Finding a Shared Spliced Motif lcsq-grondilu.pl
- Independent Alleles lia-grondilu.pl
- lrep-grondilu-p5.pl
- Maximum Matchings and RNA Secondary Structures mmch-grondilu.pl
- Finding a Protein Motif mprt-grondilu.pl
- Inferring mRNA from Protein mrna-grondilu.pl
- Distances in Trees nwck-grondilu.pl
- Open Reading Frames orf-grondilu.pl
- Perfect Matchings and RNA Secondary Structures pmch-grondilu.pl
- Partial Permutations pper-grondilu.pl
- Introduction to Random Strings prob-grondilu.pl
- Quartets qrt-grondilu.pl
- README.md
- Complementing a Strand of DNA revc-gerdr.pl
- Transcribing DNA into RNA rna-gerdr.pl
- Matching Random Motifs rstr-grondilu.pl
- Sex-Linked Inheritance sexl-grondilu.pl
- Using the Spectrum Graph to Infer Peptides sgra-grondilu.pl
- Inferring Protein from Spectrum spec-grondilu.pl
- Finding a Spliced Motif sseq-grondilu.pl
- Finding a Motif in DNA subs-grondilu.pl
- Encoding Suffix Trees suff-grondilu.pl
- Transitions and Transversions tran-grondilu.pl
- Introduction to Pattern Matching trie-grondilu.pl
Shootout
Implementations for the Computer Language Benchmark Game
- fasta.p5.pl
- Generate and write random DNA sequences fasta.p6
- k-nucleotide.p5.pl
- Repeatedly update hashtables and k-nucleotide strings k-nucleotide.p6
- Generates the Mandelbrot Set fractal mandelbrot.p6
- Perform an N-body simulation of the Jovian planets n-body-v2.p6
- n-body.p5.pl
- Perform an N-body simulation of the Jovian planets n-body.p6
- regex-dna.p5.pl
- Match DNA 8-mers and substitute nucleotides for IUB code regex-dna.p6
- Read DNA sequences and write their reverse-complement revcomp-v2.p6
- revcomp.p5.pl
- Read DNA sequences and write their reverse-complement revcomp.p6
Perl6 Tutorial Examples
Initial work in collecting Perl 6 tutorial examples
- Reading from a file 01-read-from-file.pl
- Reading from the terminal 01-read-from-terminal.pl
- Word-wrap paragraphs to a given length 01-word-wrap.pl
- Write to a file 01-write-to-file.pl
- Lazily evaluate items in a list lazy-evaluation.pl
Winter Scripting Games
Answers for the Winter Scripting Games
- Could I Get Your Phone Number? advanced-2008
- Skating on Thin Ice advanced-2008
- You Call That a Strong Password? advanced-2008
- Blackjack! advanced-2008
- One of These Things is not Like the Others beginner-2007
- Pairing Off beginner-2008
- Pairing off beginner-2008
- Pairing Off beginner-2008
- Let's Get Together beginner-2008
- Coffee Break beginner-2008
- Coffee Break beginner-2008
- Random Guess beginner-2008
- Random Guess beginner-2008
- Bowling beginner-2008
- README.md
Other examples
Other examples which aren't yet categorized