Language teachers in Europe describe what a learner can do at six levels, from A1 to C2. This site uses the same six levels for Raku. Every reader, false friend and word family is marked with one, so you can stay at your level or step one above it.
A level says what you can read and what you can write. Reading comes first: you will understand code at the next level long before you write it yourself, and that is how it should be.
A1 — First words
You can read a program of a few lines and say what it prints.
say,print, comments- variables with
my: numbers and strings + - * / %,**, and~to join stringsif,else,unlessforover a range like1..10, with$_.uc,.lc,.chars,.flip
You can write: a program that prints a table, counts to a number, or checks one condition.
Articles at A1
- CountdownA rocket counts down from ten. Read the program and guess what it prints before you run it.
- Is it a palindrome?Six words, read forwards and backwards. Guess which of them are palindromes before you run the program.
- + adds, even when the numbers are stringsIn JavaScript,
"10" + 5is"105", and in Python it is an error. In Raku it is 15, because+always adds. - == does not compare stringsIn Python and JavaScript,
==compares strings too. In Raku,==compares numbers, and strings are compared witheq.
A2 — Everyday Raku
You can read a program of a page that works with lists of things.
- arrays and hashes,
@and%,.elems,.keys,.values,.kv for @list -> $item { }, pointy blocks with one or two variables^10,.reverse,.sort,.join,.split,.words,.comb- strings with interpolation, including
{ }inside them subwith positional parameters,returnwhile,loop,last,next
You can write: a small program that keeps a list or a table and reports on it.
Articles at A2
- At the marketFive things from the market and what they cost. In what order does the program list them?
- Weather in four citiesToday’s temperature in Riga, Amsterdam, Turin and Belgrade, in Celsius and Fahrenheit, with a word for how it feels.
- @a[-1] is not the last elementIn Python and Perl, index -1 counts from the end. In Raku it does not even compile.
- 0.1 + 0.2 is exactly 0.3In Python and JavaScript,
0.1 + 0.2is not equal to0.3. In Raku it is, because0.1is stored as a fraction. - There is no length
len,.lengthandlengthdo not exist in Raku. A string has.chars, and a list has.elems. - // is not integer divisionIn Python,
7 // 2is 3. In Raku,//means "or else, if there is no value", so7 // 2is 7. - Splitting on nothing does not give you the lettersIn JavaScript and Perl, splitting on an empty string gives the characters. In Raku you also get an empty string at each end. Use
.comb. - my $n = @array is not a countIn Perl, putting an array into a scalar variable gives you its length. In Raku, the scalar holds the whole array.
- comb, words, lines, splitFour methods that cut a string into a list of pieces, and how to pick the right one.
- say, put, print, noteFour ways to print something, and why
sayshows an array with brackets whileputdoes not.
B1 — Getting around
You can read most programs written to solve a small task, and you can follow method chains.
map,grep,first,sum,min,max,.unique,.classify- the whatever star:
* * 2,*.chars - named arguments and default values
- classes with
hasattributes and methods - simple regexes:
m/ /,.match,.subst,~~ Ratarithmetic, and the difference betweensayandputgiven/when
You can write: a program of a hundred lines with a class or two, and read its error messages.
Articles at B1
- The departure boardFive trains, one small class, and three questions to the timetable — all trains in order, the trains to Rotterdam, and the first one after nine.
- Pancakes for sixA recipe for four people, scaled for six and for five. A third of a cup of sugar shows how Raku keeps fractions exact.
- map, grep, first, classifyFour methods that walk through a list and do something with each element, and how to tell which one you need.
- x, xx and XThree operators that look alike — one repeats a string, one repeats a list element, and one combines two lists.
- ==, eq, eqv, === and ~~Five ways to ask whether two things are equal, and the question each one really asks.
- Counting wordsThe three most frequent words in a sentence, written four times — with a Python, a Perl and a C accent, and as a native would write it.
- Totals per cityAdding up sales per city from a small table, written with a Python, a Perl and a C accent, and as a native would write it.
B2 — Independent
You can read code written by someone else without asking them, including code that uses the operators that make Raku different.
- signatures with types and constraints,
multisubs - roles
- sequences:
1, 2, 4 ... *, lazy lists,gather/take - metaoperators:
[+],»,Z,X,R - junctions:
any,all,none Set,Bag,Mixand their operators- small grammars, named captures
try,CATCH,die,fail
You can write: a program that someone else would accept in a code review.
Articles at B2
C1 — Fluent
You can read a module from the ecosystem and explain how it works.
- grammars with action classes
- your own operators
- containers and binding:
=and:=,is rw,is copy - phasers:
BEGIN,ENTER,LEAVE,FIRST,LAST start,await,Promise,Supply,react/whenever- introspection:
.WHAT,.^name,.^methods - traits and
is export
You can write: a module with a clear interface and tests.
C2 — Native
You can read anything written in Raku, including dense one-liners and golfed code, and say why it works.
- every operator and its precedence
- the metaobject protocol
Seqand its caching,Iterableand iterators- slangs and
EVAL, and when not to use them
You can write: code that other Raku programmers learn from.
Nothing at C2 yet.