seanpm2001 / Learn-Raku

A repository for showcasing my knowledge of the Raku programming language, and continuing to learn the language.

Home Page:https://github.com/seanpm2001/Learn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


/Camelia.svg

Learning Raku

I am not too experienced with the Raku programming language at the moment. This document will go over my knowledge of the Raku language so far.

This document used version 6.d of the Raku programming language. The version will be listed with each example.

Comments in Raku

Comments in Raku are similar to languages lika Perl, Python, Shell, etc.

# This is a single line comment
# Raku doesn't support multi-line comments as far as I know

This example works with every version of Raku

Break keyword in Raku

Raku supports the break keyword:

break

To this day, I am still not entirely sure what the break keyword does, but most languages support it.

Hello World in Raku

A hello world program in Raku is written like so:

say "Hello World"

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

Alternatively, since this is a Perl family language:

JARH program
# JARH program (Just Another Raku Hacker)
say "Just Another Raku Hacker..."

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

My keyword in Raku

Raku uses the my keyword for defining variables.

Integers in Raku

Using the my keyword, a Raku integer is defined like so:

my Int $x = 2;

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

However, defining the integer like this is optional, and can be simplified to:

my $x = 2;

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

Strings in Raku

Using the my keyword, a Raku string is defined like so:

my Str $s = "A Raku string...";

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

However, defining the string like this is optional, and can be simplified to:

my $s = "A Raku string...";

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

Classes in Raku

Raku supports OOP (Object Oriented Programming) and along with it, classes. A Raku class is defined like so:

class myRakuClass {
	say "Welcome to my Raku Class"
}

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

Factorials in Raku

Factorials in Raku are defined using the fact keyword. The keyword sub seems to be mandatory. They are written like so:

sub fact (UInt $n --> UInt) {
	return 1 if $n == 0;
	return $n * fact($n-1);
}

This example works with every version of Raku

/!\ This example has not been tested yet, and may not work

Source

The majority of my Raku knowledge comes from self-experimentation, and Wikipedia.

Other knowledge of Raku

  1. Raku is a curly bracket and semicolon language

  2. Raku has a syntax similar to Perl, see more below (goto 4)

  3. Raku uses the *.raku file extension

  4. Raku was originally known as Perl 6, but the developers of Perl decided to split it off into its own separate language, due to how much change there was.

  5. Raku is a programming language by Larry Wall

  6. Raku is a language recognized by GitHub, although GitHub also recognizes perl 6 as a separate programming language alongside Raku, but not officially anymore.

  7. Raku is an open source programming language

  8. No other knowledge of Raku at the moment.


File version: 1 (2022, Tuesday, April 19th at 4:44 pm PST)


About

A repository for showcasing my knowledge of the Raku programming language, and continuing to learn the language.

https://github.com/seanpm2001/Learn/

License:GNU General Public License v3.0


Languages

Language:Raku 100.0%