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
1 answer

Installation Requirements for mysql with DBIish on rakudo-star docker image

I was creating an own docker image based on the latest rakudo-star docker image. I wanted to use DBIish to connect to a mysql database. Unfortunately I am not able to get the DBDish::mysql to work. I've installed default-libmysqlclient-dev as you…
Martin Barth
  • 796
  • 4
  • 13
6
votes
5 answers

What's the equivalent in Perl 6 to star expressions in Python?

In Python 3, suppose you run a course and decide at the end of the semester that you’re going to drop the first and last homework grades, and only average the rest of them: def drop_first_last(grades): first, *middle, last = grades return…
chenyf
  • 5,048
  • 1
  • 12
  • 35
6
votes
1 answer

Share signature constraints across functions

Given a simple program to convert to/from bases: #!perl6 my @alphabet = ('0' .. '9', 'A' .. 'Z', 'a' .. 'z').flat; sub to-digits(Int $n is copy, Int $b where 2 <= * <= 62 --> Str) { my @digits; while $n > 0 { @digits.push(@alphabet[$n %…
Hunter McMillen
  • 59,865
  • 24
  • 119
  • 170
6
votes
2 answers

Method returning a regex in Perl 6?

I'm only beginning to study classes, so I don't understand the basics. I want a method to construct regex using attributes of the object: class TEST { has Str $.str; method reg { return rx/ << …
Eugene Barsky
  • 5,780
  • 3
  • 17
  • 40
6
votes
1 answer

How can I interact with the Github API using Perl6?

I want to use the Github API in a script and I want to use it as an experience to get better using Perl6. However, I cannot even get a simple proof of concept to work. Through some testing I realized that Github requires that you supply a valid user…
jsaigle
  • 444
  • 2
  • 7
6
votes
1 answer

Grammar.parse seems to loop forever and use 100% CPU

Reposted from the #perl6 IRC channel, by jkramer, with permission I'm playing with grammars and trying to parse an ini-style file but somehow Grammar.parse seems to loop forever and use 100% CPU. Any ideas what's wrong here? grammar Format { token…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
2 answers

urlopen method in Perl 6?

I'm translating a Python module to Perl 6, but can't find a method called urlopen, which could accept data: from six.moves.urllib import request req = request.Request(url, headers=headers) if headers.get('Content-Type') ==…
chenyf
  • 5,048
  • 1
  • 12
  • 35
6
votes
2 answers

More concise way to setup defaults for regex in perl6

To split e.g. mins-2 into component parts of units name and order, this does what I want sub split-order ( $string ) { my Str $i-s = '1'; $string ~~ / ( <-[\-\d]>+ ) ( \-?\d? ) /; $i-s = "$1" if $1 ne ''; return( "$0", +"$i-s".Int…
librasteve
  • 6,832
  • 8
  • 30
6
votes
3 answers

Is there an infix version for routine invocation in perl 6?

Say I want to apply an array of functions to an array of objects. Something like this: my $a = sub ($) { $_ * 2 }; my $b = sub ($) { $_ / 2 }; my @funcs = ($a, $b); my @ops = @funcs.roll(4); I could do say ^10 ».&» @ops; but .& is a postfix…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
1 answer

Accessing a routine's Capture from within

What's the syntax for accessing a subroutine Capture once it's called? self only works for objects, and &?ROUTINE refers to the static routine, not its state once called. So first, is it possible to access the routine's Capture from inside? If so,…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
1 answer

Perl6: check if STDIN has data

In my Perl 6 script, I want to do a (preferably non-blocking) check of standard input to see if data is available. If this is the case, then I want to process it, otherwise I want to do other stuff. Example (consumer.p6): #!/usr/bin/perl6 use…
byteunit
  • 991
  • 4
  • 15
6
votes
1 answer

Perl6 Regex Match Num

I would like to match any Num from part of a text string. So far, this (stolen from from https://docs.perl6.org/language/regexes.html#Best_practices_and_gotchas) does the job... my token sign { <[+-]> } my token decimal { \d+ } my token…
librasteve
  • 6,832
  • 8
  • 30
6
votes
1 answer

Can I forward declare a Perl 6 class I'll define later?

Can I forward declare a class that I want to load and use later without interpolating its name? I'm trying something like this: my class Digest::MD5 {}; require ::('Digest::MD5'); put Digest::MD.new.md5_hex("My awesome data to hash"); I know I can…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
6
votes
1 answer

Mixed-in object variables available in mixed-in role declaration

I was wondering how to mix in an abstract role into a variable in runtime. Here's what I came up with role jsonable { method to-json( ) { ... } } class Bare-Word { has $.word; method new ( Str $word ) { return self.bless( $word…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
0 answers

What is the perl 6 equivalent of the Perl 5 command binmode(STDOUT, ':unix:encoding(utf8):crlf')?

This is the program I am currently running with Perl 6 (Rakudo Star 2017.10 under Windows 7 x64, codepage chcp 65001) use v6; say chr(300) x 3, chr(301), 'UVW'; I expect to have exactly one line of output: ĬĬĬĭUVW but I get a mysterious second…
user2288349
  • 267
  • 2
  • 12