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

Perl6 optional function flags

How can I implement functions that take an optional flag in Perl6? For example, say that I want to invoke my function like this: format 'a b c'; or like this: format :pretty 'a b c'; How can I do this? Thanks
pistacchio
  • 56,889
  • 107
  • 278
  • 420
6
votes
3 answers

How to write lazy accessors

What is the best way to build attributes lazily? class I { has $!cheezeburger; method cheezeburger { given $!cheezeburger { when .so {return $_} default { # build $cheezeburger, set…
beasy
  • 1,227
  • 8
  • 16
6
votes
1 answer

How do I chain to an inline block in Perl 6?

I want to modify an array (I'm using splice in this example, but it could be any operation that modifies the array) and return the modified array - unlike slice, which returns the items pulled out of the array. I can do it easily by storing a block…
dmaestro12
  • 883
  • 7
  • 15
6
votes
2 answers

Counting DNA Nucleotides using perl 6

Good Afternoon, i am trying to count the number of times the letters A C T G occur in DNA sequence using perl6.i have tried other ways i am just trying to get it done in another way. Here are some of the code i came up with use v6; my…
Oluwole
  • 71
  • 4
6
votes
1 answer

Perl6: implicit and explicit import

Is it possible to write a module in a way that when the module is used with no explicit import all subroutines are imported and when it is used with explicit import only theses explicit imported subroutines are available? #!/usr/bin/env perl6 use…
sid_com
  • 24,137
  • 26
  • 96
  • 187
6
votes
4 answers

Does Perl 6 have named tuples?

I know that Swift has named tuples: let twostraws = (name: "twostraws", password: "fr0st1es") so I can say: print(twostraws.name) # twostraws but in Perl 6 I'd say: my $list = (twostraws, fr0st1es); say $list[0]; Which is not as awesome as…
chenyf
  • 5,048
  • 1
  • 12
  • 35
6
votes
1 answer

What's the easiest way to get Grammar::Tracer working on Perl6 itself?

To get an idea how perl6 parses your code, you can use the --target option: $ perl6 --target=parse -e '"Hello World".say' - statementlist: "Hello World".say - statement: 1 matches - EXPR: .say - 0: "Hello World" - value: "Hello…
Marty
  • 2,788
  • 11
  • 17
6
votes
4 answers

Can I please have an ArrayOutOfBoundsException?

In Python, if you index a collection structure with a out-of-bounds key/index, you get a slap in the face: >>> [1, 2, 3][9] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range That's an…
cat
  • 3,888
  • 5
  • 32
  • 61
6
votes
2 answers

Why are inline if statements an average of at least one-third slower than other types of if?

Consider the following Perl 6 script skeleton: my regex perlish { .*[ea]?[ui]? rl $ } my Str @words = '/usr/share/dict/words'.IO.lines; for @words -> $word { ... } base idea for the code in this question from the perl6 website's…
cat
  • 3,888
  • 5
  • 32
  • 61
6
votes
1 answer

How do I limit the number of concurrent processes spawned by Proc::Async in Perl 6?

I want to process a list of files in a subtask in my script and I'm using Proc::Async to spawn the subprocesses doing the work. The downside is that if I have a large list of files to process, it will spawn many subprocesses. I want to know how to…
CyberSkull
  • 796
  • 1
  • 7
  • 16
6
votes
2 answers

Why does 100 ~~ ^100 return false in Perl 6?

perl6 -e '100 ~~ ^100' returns False, where it looks like to me it should return True, as 100 is in the range between 0 and 100. Is this a part of the design of the Range class that I'm just not understanding here or is this a bug?
CyberSkull
  • 796
  • 1
  • 7
  • 16
6
votes
1 answer

How can I declare and use a Perl 6 module in the same file as the program?

Sometimes I don't want multiples files, especially if I'm playing around with an idea that I want to keep a nice structure that can turn into something later. I'd like to do something like this: module Foo { sub foo ( Int:D $number ) is export…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
6
votes
2 answers

Need simple parallelism example in Perl 6

I am trying to learn Perl 6 and parallelism/concurrency at the same time. For a simple learning exercise, I have a folder of 550 '.htm' files and I want the total sum of lines of code among all of them. So far, I have this: use v6; my…
Herby
  • 79
  • 4
6
votes
1 answer

What does ~ mean inside a Grammar (in Perl 6)?

I found a tilde ~ in this Config::INI Perl 6 Grammar: token header { ^^ \h* '[' ~ ']' $=<-[ \] \n ]>+ \h* <.eol>+ } There are no tildes ~ in the text I am processing. I know that '[' ~ ']' is important because omitting any or all of '[', ~,…
Christopher Bottoms
  • 11,218
  • 8
  • 50
  • 99
6
votes
1 answer

Sockets code in Rakudo Perl

I've been trying to run some sockets code in Rakudo Perl (freshly built from the repository at http://github.com/rakudo/rakudo) but the implementation of IO::Socket::INET appears to be incomplete. The code I'm trying to run is here:…
Ankur Sethi
  • 3,508
  • 5
  • 23
  • 17