SUPPORT THE WORK

GetWiki

Raku (programming language)

ARTICLE SUBJECTS
aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
ARTICLE TYPES
essay  →
feed  →
help  →
system  →
wiki  →
ARTICLE ORIGINS
critical  →
discussion  →
forked  →
imported  →
original  →
Raku (programming language)
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{short description|Programming language derived from Perl}}







factoids
dynamic typing>Dynamic, gradual| scope = | implementations = Rakudo| dialects = Perl, Ruby (programming language)>Ruby, Smalltalk, Haskell (programming language),HTTP://WWW.PERLFOUNDATION.ORG/PERL6/INDEX.CGI?GLOSSARY_OF_TERMS_AND_JARGONDATE=2011-02-28PUBLISHER=THE PERL FOUNDATIONARCHIVE-URL=HTTPS://WEB.ARCHIVE.ORG/WEB/20120121145808/HTTP://WWW.PERLFOUNDATION.ORG/PERL6/INDEX.CGI?GLOSSARY_OF_TERMS_AND_JARGONURL-STATUS=DEAD, JavaScriptPerl,HTTP://PUGS.BLOGS.COM/PUGS/2010/04/HOW-TO-IMPLEMENT-PERL-6-IN-10.HTMLDATE=2010-04-21AUDREY TANG, Haskell (programming language)>Haskell, AntLang| platform = | operating system = Cross-platformGNU General Public License or Artistic License > Artistic License 2URL=HTTPS://DOCS.RAKU.ORG/LANGUAGE/MODULES#BASIC_STRUCTURE, 2022-08-19, raku.org}}}}Raku is a member of the Perl family of programming languages.WEB,weblink About Perl, 2020-06-11, perl.org, "Perl" is a family of languages, "Raku" (formerly known as "Perl 6") is part of the family, but it is a separate language which has its own development team. Its existence has no significant impact on the continuing development of "Perl"., Formerly known as Perl 6, it was renamed in October 2019.WEB,weblink Perl 6 renamed to Raku, LWN.net, 15 October 2019, 16 October 2019, WEB,weblink TPF response to Raku rename, 29 October 2019, Raku introduces elements of many modern and historical languages. Compatibility with Perl was not a goal, though a compatibility mode is part of the specification. The design process for Raku began in 2000.

History

{{Quotation|text=In Perl 6, we decided it would be better to fix the language than fix the user.|author=Larry WallBOOK, Masterminds of Programming: Conversations with the Creators of Major Programming Languages, Federico, Biancuzzi, Shane, Warden, 2009, "O'Reilly Media, Inc.", 978-0596515171,weblink }}The Raku design process was first announced on 19 July 2000, on the fourth day of that year's Perl Conference,WEB, Report from the Perl Conference,weblink Kline, Joe, 2000-08-21, by Larry Wall in his State of the Onion 2000 talk.WEB, State of the Onion 2000, Wall, Larry, O'Reilly Network,weblink 2000, Larry Wall, At that time, the primary goals were to remove "historical warts" from the language; "easy things should stay easy, hard things should get easier, and impossible things should get hard"; a general cleanup of the internal design and APIs. The process began with a series of requests for comments or "RFCs". This process was open to all contributors, and left no aspect of the language closed to change.WEB, About Perl 6 RFCs, The Perl Foundation,weblink 2000, Once the RFC process was complete, Wall reviewed and classified each of the 361 requests received. He then began the process of writing several "Apocalypses", using (wikt:apocalypsis#English|the original meaning of the term), "revealing".WEB,weblink Apocalypse 1: The Ugly, the Bad, and the Good, Wall, Larry, 2001-04-02, While the original goal was to write one Apocalypse for each chapter of Programming Perl, it became obvious that, as each Apocalypse was written, previous Apocalypses were being invalidated by later changes. For this reason, a set of Synopses were published, each one relating the contents of an Apocalypse, but with any subsequent changes reflected in updates. Today, the Raku specification is managed through the "roast" testing suite,WEB, Raku test suite, GitHub,weblink 2019, while the Synopses are kept as a historical reference.WEB, Larry Wall and the Perl 6 designers, Perl 6 Design Documents,weblink 2015, There are also a series of (wikt:exegesis#English|Exegeses) written by Damian Conway that explain the content of each Apocalypse in terms of practical usage. Each Exegesis consists of code examples along with discussion of the usage and implications of the examples.WEB,weblink Exegeses, The Perl Foundation, 2001, There are three primary methods of communication used in the development of Raku today. The first is the raku IRC channel on Libera Chat. The second is a set of mailing lists.WEB, Raku Community, The Raku Programming Language,weblink 2022, The third is the Git source code repository hosted at GitHub.WEB, Raku, GitHub,weblink 2022-08-19,

Initial goals and implications

The major goal Wall suggested in his initial speech was the removal of historical warts. These included the confusion surrounding sigil usage for containers, the ambiguity between the select functions, and the syntactic impact of bareword filehandles. There were many other problems that Perl programmers had discussed fixing for years that were explicitly addressed by Wall in his speech.{{citation needed|date=July 2019}}An implication of these goals was that Perl 6 would not have backward compatibility with the existing Perl codebase. This meant that some code which was correctly interpreted by a Perl 5 compiler would not be accepted by a Perl 6 compiler. Since backward compatibility is a common goal when enhancing software, the breaking changes in Perl 6 had to be stated explicitly. The distinction between Perl 5 and Perl 6 became so large that eventually Perl 6 was renamed Raku.

Mascot

(File:FOSDEM 2015 Larry Wall and Camelia the Perl6 logo.jpg|thumbnail|Larry Wall and Camelia)The language's mascot is "Camelia, the Raku bug".WEB
,weblink
, Perl creator hints at imminent release of long-awaited Perl 6
, Joab
, Jackson
, IDG News Service
, 23 July 2010
, 2015-02-08
, Her name is a nod to the camel mascot associated with Perl, and her form, in the pun-loving tradition of the Perl community, is a play on "software bug". Spiral designs embedded in her butterfly-like wings resemble the characters "P6", the favored nickname for Perl 6, and off-center eye placement is an intentional pun on "Wall-eyed".WEB
,weblink
, Larry Wall in IRC chat log
, 15 January 2016
, 2017-11-10
, One of the goals behind the lively and colorful design of the logo was to discourage misogyny in the community and for it to be an opportunity for those of "masculine persuasion" to show their sensitive side.WEB
,weblink
, Archived "Logo considerations" email from Larry Wall
, GitHub
, 24 March 2009
, 2017-11-10
,

Implementations

{{As of|2017}}, only the Rakudo implementation is under active development. No implementation will be designated as the official Raku implementation; rather, "Raku is anything that passes the official test suite."Rakudo Perl 6WEB,weblink rakudo/rakudo - GitHub, Github.com, 2013-09-21, WEB,weblink The compiler formerly known as 'perl6', Michaud, Patrick, 2008-01-16, dead,weblink" title="web.archive.org/web/20120218080103weblink">weblink 2012-02-18, targets a number of virtual machines, such as MoarVM, the Java Virtual Machine, and JavaScript. MoarVM is a virtual machine built especially for RakudoWEB, Worthington, Jonathan, MoarVM: A virtual machine for NQP and Rakudo,weblink 6guts, 31 May 2013, 24 July 2013, and the NQP Compiler Toolchain.WEB,weblink NQP - Not Quite Perl at github, GitHub, 2022-05-29, 2022-05-29, There is a layer between Raku and the virtual machines called Not Quite Perl 6, or NQP, which implements Raku rules for parsing Raku, as well as an abstract syntax tree and backend-specific code generation. Large portions of Rakudo are written in Raku itself, or in its subset NQP. Rakudo is not a completely self-hosting implementation, nor are there concrete plans at this point to make Rakudo a bootstrapping compiler.

Historical implementations

Pugs was an initial implementation of Perl 6 written in Haskell. Pugs used to be the most advanced implementation of Perl 6, but since mid 2007 it is mostly dormant (with updates made only to track the current version of GHC). As of November 2014 Pugs was not being actively maintained.WEB,weblink Feature comparison of Perl 6 compilers,weblink 7 February 2019, dead, In 2007, v6-MiniPerl6 ("mp6") and its reimplementation, v6-KindaPerl6 ("kp6") were written as a means to bootstrap the Perl-6.0.0 STD, using Perl 5. The STD is a full grammar for Perl 6 and is written in Perl 6. In theory, anything capable of parsing the STD and generating executable code is a suitable bootstrapping system for Perl 6. kp6 is currently compiled by mp6 and can work with multiple backends.WEB,weblink Perl 6 STD, Wall, Larry, GitHub, 2007, etal, WEB,weblink mp6/kp6 FAQ, 2006, Perl 6 development team, mp6 and kp6 are not full Perl 6 implementations and are designed only to implement the minimum featureset required to bootstrap a full Perl 6 compiler.Yapsi was a Perl 6 compiler and runtime written in Perl 6 itself. As a result, it required an existing Perl 6 interpreter, such as one of the Rakudo Star releases, in order to run.WEB,weblink Yapsi README, GitHub, 2011, Niecza, another major Perl 6 implementation effort, focused on optimization and efficient implementation research. It targets the Common Language Infrastructure.WEB
,weblink
, Niecza README.pod
, O'Rear
, Stefan
, GitHub
, 29 November 2011
, 2012-01-12
,

Module system

The Raku specification requests that modules be identified by name, version, and authority.WEB,weblink Synopsis 11: Modules, Wall, Larry, 2004, It is possible to load only a specific version of a module, or even two modules of the same name that differ in version or authority. As a convenience, aliasing to a short name is provided.CPAN, the Perl module distribution system, does not yet handle Raku modules. Instead a prototype module system is in use.WEB,weblink Perl 6 Modules Directory, Modules.raku.org, 2020-05-17,

Major changes from Perl

Perl and Raku differ fundamentally, though in general the intent has been to "keep Raku Perl", so that Raku is clearly "a Perl programming language". Most of the changes are intended to normalize the language, to make it easier for novice and expert programmers alike to understand, and to make "easy things easier and hard things more possible".

A specification

A major non-technical difference between Perl and Raku is that Raku began as a specification.WEB,weblink Synopsis 1: Overview, Wall, Larry, 2004-08-10, This means that Raku can be re-implemented if needed, and it also means that programmers do not have to read the source code for the ultimate authority on any given feature. In contrast, in Perl, the official documentation is not considered authoritative and only describes the behavior of the actual Perl interpreter informally. Any discrepancies found between the documentation and the implementation may lead to either being changed to reflect the other, a dynamic which drives the continuing development and refinement of the Perl releases.

A type system

In Raku, the dynamic type system of Perl has been augmented by the addition of static types.WEB,weblink Synopsis 2: Bits and Pieces, Wall, Larry, 2009-05-20, For example:my Int $i = 0;my Rat $r = 3.142;my Str $s = "Hello, world";However, static typing remains optional, so programmers can do most things without any explicit typing at all:my $i = "25" + 10; # $i is 35Raku offers a gradual typing system, whereby the programmer may choose to use static typing, use dynamic typing, or mix the two.

Formal subroutine parameter lists

Perl defines subroutines without formal parameter lists at all (though simple parameter counting and some type checking can be done using Perl's "prototypes"). Subroutine arguments passed in are aliased into the elements of the array @_. If the elements of @_ are modified, the changes are reflected in the original data.Raku introduces true formal parameters to the language.WEB,weblink Synopsis 6: Subroutines, Wall, Larry, 2003-03-21, In Raku, a subroutine declaration looks like this:sub do_something(Str $thing, Int $other) {
...
}As in Perl, the formal parameters (i.e., the variables in the parameter list) are aliases to the actual parameters (the values passed in), but by default, the aliases are constant so they cannot be modified. They may be declared explicitly as read-write aliases for the original value or as copies using the is rw or is copy directives respectively should the programmer require them to be modified locally.

Parameter passing modes

Raku provides three basic modes of parameter passing: positional parameters, named parameters, and slurpy parameters.Positional parameters are the typical ordered list of parameters that most programming languages use. All parameters may also be passed by using their name in an unordered way. Named-only parameters (indicated by a : before the parameter name) can only be passed by specifying its name, i.e. it never captures a positional argument. Slurpy parameters (indicated by an * before the parameter name) are Raku's tool for creating variadic functions. A slurpy hash will capture remaining passed-by-name parameters, whereas a slurpy array will capture remaining passed-by-position parameters.Here is an example of the use of all three parameter-passing modes:sub somefunction($a, $b, :$c, :$d, *@e) {
...
}somefunction(1, 2, :d(3), 4, 5, 6); # $a=1, $b=2, $d=3, @e=(4,5,6)Positional parameters, such as those used above, are always required unless followed by ? to indicate that they are optional. Named parameters are optional by default, but may be marked as required by adding ! after the variable name. Slurpy parameters are always optional.

Blocks and closures

Parameters can also be passed to arbitrary blocks, which act as closures. This is how, for example, for and while loop iterators are named. In the following example, a list is traversed, 3 elements at a time, and passed to the loop's block as the variables, $a, $b, $c.WEB,weblink Synopsis 4: Blocks and Statements, Wall, Larry, 2009-05-20, for @list -> $a, $b, $c {
...
}This is generally referred to as a "pointy sub" or "pointy block", and the arrow behaves almost exactly like the sub keyword, introducing an anonymous closure (or anonymous subroutine in Perl terminology).

Sigil invariance

In Perl, sigils – the punctuation characters that precede a variable name – change depending on how the variable is used:
# Perl code


my {{font color|red|@}}array = ('a', 'b', 'c');
my $element = {{font color|red|$}}array[1]; # $element equals 'b',
my @extract = {{font color|red|@}}array[1, 2]; # @extract equals ('b', 'c')
my $element = {{font color|red|@}}array[1]; # 'b' comes with a warning (5.10 option)
In Raku, sigils are invariant, which means that they do not change based on whether it is the array or the array element that is needed:
# Raku code
my {{font color|red|@}}array = 'a', 'b', 'c';
my $element = {{font color|red|@}}array[1]; # $element equals 'b'
my @extract = {{font color|red|@}}array[1]; # @extract equals ('b')
my @extract = {{font color|red|@}}array[1, 2]; # @extract equals ('b', 'c')
The variance in Perl is inspired by number agreement in English and many other natural languages:
"This apple." # $a CORRECT
"These apples." # @a CORRECT
"This third apple." # $a[3] CORRECT
"These third apple." # @a[3] WRONG
However, this conceptual mapping breaks down when using references, since they may refer to data structures even though they are scalars. Thus, dealing with nested data structures may require an expression of both singular and plural form in a single term:
  1. Perl code: retrieve a list from the leaf of a hash containing hashes that contain arrays
my @trans_verbs = @{ $dictionary{ 'verb' }{ 'transitive' } };This complexity has no equivalent either in common use of natural language or in other programming languages,{{dubious|date=October 2015}} and it causes high cognitive load when writing code to manipulate complex data structures. This is the same code in Raku:
  1. Raku code: retrieve a list from the leaf of a hash containing hashes that contain arrays
my @trans_verbs = %dictionary;

Object-oriented programming

Perl supports object-oriented programming via a mechanism known as blessing. Any reference can be blessed into being an object of a particular class. A blessed object can have methods invoked on it using the "arrow syntax" which will cause Perl to locate or "dispatch" an appropriate subroutine by name, and call it with the blessed variable as its first argument.While extremely powerful, it makes the most common case of object orientation, a struct-like object with some associated code, unnecessarily difficult. In addition, because Perl can make no assumptions about the object model in use, method invocation cannot be optimized very well.In the spirit of making the "easy things easy and hard things possible", Raku retains the blessing model and supplies a more robust object model for the common cases.WEB,weblink Synopsis 12: Objects, Wall, Larry, 2006-08-18, For example, a class to encapsulate a Cartesian point could be defined and used this way:class Point is rw {
has $.x;
has $.y;

method distance( Point $p ) {
sqrt(($!x - $p.x) 2 + ($!y - $p.y) 2)
}

method distance-to-center {
self.distance: Point.new(x => 0, y => 0)
}
}my $point = Point.new( x => 1.2, y => -3.7 );say "Point's location: (", $point.x, ', ', $point.y, ')';
  1. OUTPUT: Point's location: (1.2, -3.7)
  1. Changing x and y (note methods "x" and "y" used as lvalues):
$point.x = 3;$point.y = 4;say "Point's location: (", $point.x, ', ', $point.y, ')';
  1. OUTPUT: Point's location: (3, 4)
my $other-point = Point.new(x => -5, y => 10);$point.distance($other-point); #=> 10$point.distance-to-center; #=> 5The dot replaces the arrow in a nod to the many other languages (e.g. C++, Java, Python, etc.) that have coalesced around dot as the syntax for method invocation.In the terminology of Raku, $.x is called an "attribute". Some languages call these fields or members. The method used to access an attribute is called an "accessor". An auto-accessor method is a method created automatically and named after the attribute's name, as the method x is in the example above. These accessor functions return the value of the attribute. When a class or individual attribute is declared with the is rw modifier (short for "read/write"), the auto-accessors can be passed a new value to set the attribute to, or it can be directly assigned to as an lvalue (as in the example). Auto-accessors can be replaced by user-defined methods, should the programmer desire a richer interface to an attribute. Attributes can only be accessed directly from within a class definition via the $! syntax regardless of how the attributes are declared. All other access must go through the accessor methods.The Raku object system has inspired the Moose framework that introduces many of Raku's OOP features to Perl.{{clarify|What does perl mean here? Perl5?|date=September 2020}}

Inheritance, Roles and Classes

Inheritance is the technique by which an object or type can re-use code or definitions from existing objects or types. For example, a programmer may want to have a standard type but with an extra attribute. Inheritance in other languages, such as Java, is provided by allowing Classes to be sub-classes of existing classes.Raku provides for inheritance via Classes, which are similar to Classes in other languages, and Roles.Roles in Raku take on the function of interfaces in Java, mixins in Ruby, and traitsWEB, Traits,weblink The Software Composition Group, 2003, 22 September 2006,weblink" title="web.archive.org/web/20060811170712weblink">weblink 11 August 2006, dead, in PHP and in the Smalltalk variant Squeak. These are much like classes, but they provide a safer composition mechanism.WEB, Day 18: Roles,weblink 2009, Jonathan, Worthington, These are used to perform composition when used with classes rather than adding to their inheritance chain. Roles define nominal types; they provide semantic names for collections of behavior and state. The fundamental difference between a role and a class is that classes can be instantiated; roles are not.WEB, The Why of Perl Roles,weblink chromatic, 2009, chromatic (programmer), Although Roles are distinct from Classes, it is possible to write Raku code that directly instantiates a Role or uses a Role as a type object, Raku will automatically create a class with the same name as the role, making it possible to transparently use a role as if it were a class.WEB,weblink Object orientation, docs.raku.org, 2019-10-24, Essentially, a role is a bundle of (possibly abstract) methods and attributes that can be added to a class without using inheritance. A role can even be added to an individual object; in this case, Raku will create an anonymous subclass, add the role to the subclass, and change the object's class to the anonymous subclass.For example, a Dog is a Mammal because dogs inherit certain characteristics from Mammals, such as mammary glands and (through Mammal's parent, Vertebrate) a backbone. On the other hand, dogs also may have one of several distinct types of behavior, and these behaviours may change over time. For example, a Dog may be a Pet, a Stray (an abandoned pet will acquire behaviours to survive not associated with a pet), or a Guide for the blind (guide dogs are trained, so they do not start life as guide dogs). However, these are sets of additional behaviors that can be added to a Dog. It is also possible to describe these behaviors in such a way that they can be usefully applied to other animals, for example, a Cat can equally be a Pet or Stray. Hence, Dog and Cat are distinct from each other, while both remain within the more general category Mammal. So Mammal is a Class and Dog and Cat are classes that inherit from Mammal. But the behaviours associated with Pet, Stray, and Guide are Roles that can be added to Classes, or objects instantiated from Classes.class Mammal is Vertebrate {
...
}class Dog is Mammal {
...
}role Pet {
...
}role Stray {
...
}role Guide {
...
}Roles are added to a class or object with the does keyword. In order to show inheritance from a class, there is a different keyword is. The keywords reflect the differing meanings of the two features: role composition gives a class the behavior of the role, but doesn't indicate that it is truly the same thing as the role.class GuideDog is Dog does Guide {
...
} # Subclass composes rolemy $dog = new Dog;$dog does Guide; # Individual object composes roleAlthough roles are distinct from classes, both are types, so a role can appear in a variable declaration where one would normally put a class. For example, a Blind role for a Human could include an attribute of type Guide; this attribute could contain a Guide Dog, a Guide Horse, a Guide Human, or even a Guide Machine.class Human {
has Dog $dog; # Can contain any kind of Dog, whether it does the
... # Guide role or not
}role Blind {
has Guide $guide; # Can contain any object that does the Guide role,
... # whether it is a Dog or something else
}

Regular expressions

Perl's regular expression and string-processing support has always been one of its defining features.WEB,weblink Essential Perl: String Processing with Regular Expressions, Parlante, Nick, 2000, Since Perl's pattern-matching constructs have exceeded the capabilities of regular language expressions for some time,WEB,weblink PERL5 Regular Expression Description, Christiansen, Tom, 1996, Perl's regexps "aren't" -- that is, they aren't "regular" because backreferences per sed and grep are also supported, which renders the language no longer strictly regular, 25 March 2010,weblink" title="web.archive.org/web/20100331122815weblink">weblink 31 March 2010, dead, Raku documentation exclusively refers to them as regexes, distancing the term from the formal definition.Raku provides a superset of Perl features with respect to regexes, folding them into a larger framework called "rules" which provide the capabilities of context-sensitive parsing formalisms (such as the syntactic predicates of parsing expression grammars and ANTLR), as well as acting as a closure with respect to their lexical scope.WEB,weblink Synopsis 5: Regexes and Rules, Wall, Larry, 2009-05-20, Rules are introduced with the rule keyword which has a usage quite similar to subroutine definition. Anonymous rules can also be introduced with the regex (or rx) keyword, or they can simply be used inline as regexps were in Perl via the m (matching) or s (substitute) operators.In Apocalypse 5, Larry Wall enumerated 20 problems with "current regex culture". Among these were that Perl's regexes were "too compact and 'cute'", had "too much reliance on too few metacharacters", "little support for named captures", "little support for grammars", and "poor integration with 'real' language".WEB,weblink Apocalypse 5: Pattern Matching, Wall, Larry, 2002-06-04,

Syntactic simplification

Some Perl constructs have been changed in Raku, optimized for different syntactic cues for the most common cases. For example, the parentheses (round brackets) required in control flow constructs in Perl are now optional:if is-true() {
for @array {
...
}
}Also, the , (comma) operator is now a list constructor, so enclosing parentheses are no longer required around lists. The code@array = 1, 2, 3, 4;now makes @array an array with exactly the elements '1', '2', '3', and '4'.

Chained comparisons

Raku allows comparisons to "chain". That is, a sequence of comparisons such as the following is allowed:if 20 UInt ) {
if $n == 0 { 1 }
else { $n * fact($n-1) }
}
  1. Using recursion (with `if` as statement modifier)
sub fact( UInt $n --> UInt ) {
return 1 if $n == 0;
return $n * fact($n-1);
}
  1. Using recursion (with `when` construct)
sub fact( UInt $n --> UInt ) {
when $n == 0 { 1 }
default { $n * fact($n-1) }
}
  1. Using the ternary operator
sub fact( UInt $n --> UInt ) {
$n == 0 ?? 1 !! $n * fact($n-1)
}
  1. Using multiple dispatch
multi fact(0) { 1 }multi fact( UInt $n --> UInt ) {
$n * fact($n - 1)
}
  1. Using the reduction metaoperator
sub fact( UInt $n --> UInt ) {
[*] 1..$n
}
  1. Creating a factorial operator and using the reduction metaoperator
sub postfix:( UInt $n --> UInt ) { [*] 1..$n }
  1. Using `state` declarator to create a memoized factorial
sub fact( UInt $n --> UInt ) {
state %known = 0 => 1;
return %known{$n} if %known{$n}:exists;
%known{$n} = $n * fact($n-1);
return %known{$n};
}

Quicksort

Quicksort is a well-known sorting algorithm. A working implementation{{efn|Unless the implementation does something fancy and mysterious behind the scenes, the maximal possible recursion depth is the length of the list, making this implementation unsuitable for big data. Recursion depth can be limited to log2(list_length) by iterating into the larger of partitions before and after, and only recursing into the smaller partition.}} using the functional programming paradigm can be succinctly written in Raku:
  1. Empty list sorts to the empty list
multi quicksort([]) { () }
  1. Otherwise, extract first item as pivot...
multi quicksort([$pivot, *@rest]) {
# Partition.
my @before = @rest.grep(*
< $pivot);
my @after = @rest.grep(* >= $pivot);


# Sort the partitions.
flat (quicksort(@before), $pivot, quicksort(@after))
}{{notelist}}

Tower of Hanoi

Tower of Hanoi is often used to introduce recursive programming in computer science. This implementation uses Raku's multi-dispatch mechanism and parametric constraints:multi sub hanoi(0, $, $, $) { } # No disk, so do not do anythingmulti sub hanoi($n, $a = 'A', $b = 'B', $c = 'C') { # Start with $n disks and three pegs A, B, C
hanoi $n - 1, $a, $c, $b; # firstly move top $n - 1 disks from A to B
say "Move disk $n from peg $a to peg $c"; # then move last disk from A to C
hanoi $n - 1, $b, $a, $c; # lastly move $n - 1 disks from B to C
}

Books

In the history of Raku there were two waves of book writing. The first wave followed the initial announcement of Perl 6 in 2000. Those books reflect the state of the design of the language of that time, and contain mostly outdated material. The second wave, that followed the announcement of Version 1.0 in 2015, includes several books that have already been published and some others that are in the process of being written.

Books published before Perl 6 version 1.0 (known as version 6.c)

  • BOOK, Randal, Allison, Sugalski, Dan, Tötsch, Leopold, Perl 6 Essentials, 1st, O'Reilly Media, 2003, 978-0-596-00499-6,
  • BOOK, Randal, Allison, Sugalski, Dan, Tötsch, Leopold,weblink Perl 6 and Parrot Essentials, 2nd, O'Reilly Media, 2004, 978-0-596-00737-9,
  • BOOK, Walters, Scott,weblink Perl 6 Now: The Core Ideas Illustrated with Perl 5, Expert's Voice in Open Source, 2004-12-15, 978-1-59059-395-0,
Also, a book dedicated to one of the first Perl 6 virtual machines, Parrot, was published in 2009.
  • BOOK, Randal, Allison, Whitworth, Andrew,weblink Parrot Developer's Guide: Pir, Onyx Neon Press, 2009-06-15, 978-0-9779201-2-9,

Books published after Perl 6 version 1.0 (known as version 6.c)

  • BOOK, Andrew, Shitov,weblink Perl 6 at a Glance, 2017, 978-90-821568-3-6,
  • BOOK, Rosenfeld, Laurent, Downey, Allen B., Think Perl 6, 2017, 978-1-4919-8055-2,weblink
  • BOOK, Merelo, J. J., Learning to program with Perl 6: First Steps: Getting into programming without leaving the command line, Learning to Program with Perl, 2017-07-09, 978-1-5217-9578-1,weblink
  • BOOK, Lenz, Moritz, Perl 6 Fundamentals, Apress, 2017-07-27, 978-1-4842-2898-2,weblink
  • BOOK, Shitov, Andrew, Perl 6 Deep Dive, 2017-09-07, 978-1-78728-204-9,weblink
  • BOOK, Shitov, Andrew,weblink Using Perl 6, 2017, 978-90-821568-1-2,
  • BOOK, Gabor, Szabo, 3 December 2017,weblink Web Application Development in Perl 6, Author,
  • BOOK, Lenz, Moritz,weblink Parsing with Perl 6 Regexes and Grammars: A Recursive Descent into Parsing, Apress, 2017-12-04, 978-1-4842-3228-6,
  • BOOK, Foy, Brian D., Learning Perl 6, O'Reilly Media, 2018, 978-1-4919-7768-2,weblink

Books published with the new Raku name

  • BOOK, Shitov, Andrew,weblink Using Raku: 100 Programming Challenges Solved in the Raku Programming Language, 2nd, 2019-10-13, 978-90-821568-8-1,
  • BOOK, Shitov, Andrew,weblink Raku One-Liners: Getting the Most of Raku's Expressive Syntax for Your Daily Routines, 2019-10-18, 978-90-821568-9-8,
  • BOOK, Lenz, Moritz,weblink Raku Fundamentals: A Primer with Examples, Projects, and Case Studies, Apress, 2020-09-06, 978-1-4842-6108-8,

References

{{Reflist|30em}}

External links

  • {{Official website}}
{{Perl|state=collapsed}}{{Use dmy dates|date=October 2018}}

- content above as imported from Wikipedia
- "Raku (programming language)" does not exist on GetWiki (yet)
- time: 9:21am EDT - Sat, May 18 2024
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
GETWIKI 23 MAY 2022
GETWIKI 09 JUL 2019
Eastern Philosophy
History of Philosophy
GETWIKI 09 MAY 2016
GETWIKI 18 OCT 2015
M.R.M. Parrott
Biographies
GETWIKI 20 AUG 2014
CONNECT