Questions tagged [raku]

For questions relating to the Raku programming language (formerly known as Perl 6).

Raku

Raku is an expressive and feature-rich programming language designed by Larry Wall and developed by the community.

Features include:

  • Object-oriented programming
  • Functional programming primitives
  • Parallelism
  • Concurrency
  • Asynchrony
  • Definable grammars for pattern matching and generalized string processing
  • Optional and gradual typing
  • Extensive Unicode support from code points to grapheme clusters
  • Multiple dispatch
  • Introspection
  • Rational numbers

is a Raku implementation that targets multiple back ends.

The MoarVM back end is recommended for normal use, but back ends for the Java Virtual Machine and JavaScript are also under active development.

The Rakudo implementation shipped a first official release named “коледа” on December 25, 2015. Most of the specification is frozen, and optimizations are ongoing.

Official links

1993 questions
6
votes
2 answers

Perl 6 Grammar doesn't match like I think it should

I'm doing Advent of Code day 9: You sit for a while and record part of the stream (your puzzle input). The characters represent groups - sequences that begin with { and end with }. Within a group, there are zero or more other things, separated by…
mscha
  • 6,509
  • 3
  • 24
  • 40
6
votes
1 answer

How to concatenate two Sets of strings in Perl 6?

Is there an idiomatic way or a built-in method to concatenate two Sets of strings? Here's what I want: > my Set $left = .Set set(begin_ start_) > my Set $right = .Set set(end finish) > my Set $left_right = ($left.keys X~…
Eugene Barsky
  • 5,780
  • 3
  • 17
  • 40
6
votes
1 answer

If I reassigned OUT in Perl 6, how can I change it back to stdout?

A very simple question, but I can't easily find an answer. I want all say in a block to go to a file. But then I want my output to return to STDOUT. How to do that? my $fh_foo = open "foo.txt", :w; $*OUT = $fh_foo; say "Hello, foo! Printing to…
Eugene Barsky
  • 5,780
  • 3
  • 17
  • 40
6
votes
1 answer

Special symbols as elements of strings array in Perl 6

If I understand correctly, when I assign values to an array of strings with < ... >, I should escape special symbols with \: > my @array = < \\ a b> [\ a b] > my @array = < \< a b> [< a b] > my @array = < \ [
Eugene Barsky
  • 5,780
  • 3
  • 17
  • 40
6
votes
2 answers

Does Perl 6 performance suffer by using rationals for decimal numbers

I understand that Perl 6 implements decimals as rationals wherever possible in order to avoid floating point issues that are present in most other languages. Has anybody done benchmarking or have an understanding of the performance penalty of doing…
Ross Attrill
  • 2,594
  • 1
  • 22
  • 31
6
votes
3 answers

Perl 6 to show index while looping through a list

When looping through a list (or an array), is there a way to know the index of the current element inside the loop? Of course, the problem can be solved by looping through indices: my @aa = 8 .. 12; say "$_\t@aa[$_]" for 0 ..^ @aa.elems; But maybe…
Eugene Barsky
  • 5,780
  • 3
  • 17
  • 40
6
votes
1 answer

Creating a Perl 6 module containing Perl 5 utility scripts in bin/

Perl 6 script in a Perl 5 module distribution I can include a Perl 6 script in a Perl 5 module distribution: # Create a new module dzil new My::Dist cd My-Dist/ # Add necessary boilerplate echo '# ABSTRACT: boilerplate' >> lib/My/Dist.pm # Create…
Christopher Bottoms
  • 11,218
  • 8
  • 50
  • 99
6
votes
2 answers

Installation of modules Perl 6 failed - No compiler available for Perl v6.c

I installed Rakudo, the Perl 6 interpreter, by: sudo apt-get install rakudo I am following a tutorial about installation of Perl 6 modules: http://perl6maven.com/how-to-install-perl6-modules And in the last step I get this error: perl6…
Daniel
  • 7,684
  • 7
  • 52
  • 76
6
votes
3 answers

Is that one argument or none for a Perl 6 block?

What is the Perl 6 way to tell the difference between an argument and no argument in a block with no explicit signature? I don't have any practical use for this, but I'm curious. A block with no explicit signature puts the value into $_: my &block…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
6
votes
1 answer

Start REPL with definitions loaded from file

Is there a way to start the Perl 6 REPL with definitions loaded from a file? I.e. let's say I have this in test.p6: sub abc() { say 123; } I'd like to be able to start the perl6 REPL and load that file so that I can use abc interactively.
dharmatech
  • 8,979
  • 8
  • 42
  • 88
6
votes
1 answer

Does Perl 6 natively support Design by Contract?

It is listed as a language with native DbC support on the Wikipedia beside Eiffel and Spec#, but I can't find any mention whatsoever in the docs or in the test suite.
catemperor
  • 163
  • 2
  • 6
6
votes
4 answers

How can I autoflush a Perl 6 filehande?

There are a couple of answers for Perl 6 back in its Parrot days and they don't seem to work currently: This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda implementing Perl 6.c. The answer to Does perl6 enable…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
6
votes
2 answers

How to derive own distinguish type from Int?

I would like to define two data types in Perl 6 deriving from Int but being incompatible with Int or each other at the same time. For instance: Distance derived from Int with a range 0 up to 32000, and Offset derived from Int with a range from…
chi
  • 309
  • 1
  • 4
6
votes
2 answers

How to be aware of missing values during multi-value iteration in Perl 6?

During multi-value iteration, if we run out of values, the last group of values will not be handled in the current version of Rakudo. my @arr = 1, 2, 3, 4, 5, 6 for @arr -> $a, $b, $c, $d { say $a say $b say $c say $d } The result…
hwding
  • 840
  • 10
  • 22
6
votes
1 answer

Why is Perl 6's unwrap method a method of Routine?

There's an unwrap method, but the way it seems I'm supposed to use it isn't the way it should be used. It seems like it should either be a standalone routine or a method in a different class. What am I missing? It appears that it doesn't care what…
brian d foy
  • 129,424
  • 31
  • 207
  • 592