📘 Disclaimer: This book is published under a Creative Commons license and is freely available via GitHub.

Raku One-Liners Andrew Shitov pdf

Raku One-Liners Andrew Shitov (PDF) -- Andrew Shitov -- bookcover

Raku One-Liners Andrew Shitov

✒️ By Andrew Shitov



Raku One-Liners by Andrew Shitov is a compact guide packed with clever code snippets and quick solutions. If you love concise, elegant programming, this PDF is a delightful read. It’s perfect for anyone wanting to explore Raku’s unique capabilities in a fun, hands-on way.


Contents of the Book

Command-Line Options

  • Using command-line options
    • -e
    • -n
    • -p
  • Short one-line examples
    • Double-space a file
    • Remove all blank lines
    • Number all lines in a file
    • Convert all text to uppercase
    • Strip whitespace from beginning and end of each line
    • Print the first line of a file
    • Print the first 10 lines
  • Reading files with $*ARGFILES
  • $*ARGFILES and MAIN

Working with Files

  • Renaming files
  • Merging files horizontally
  • Reversing a file

Working with Numbers

  • Grepping multiples of 3 and 5
  • Generating random integers
  • Working with big numbers
  • Testing palindromic numbers
  • Adding even Fibonacci numbers
  • Playing with Fibonacci numbers
  • Calculating distance between two points
  • Playing with prime numbers
  • Using map and Seq to approximate π
  • Computing totals
  • Numbers equal to sum of factorials of their digits
  • “42 via the cubes”

Working with Strings

  • Generating random passwords
  • Working with Unicode

Working with Dates

  • Getting today’s date
  • Counting dates in a century matching a condition
  • Alternative solution to the same problem

Raku Syntax

  • Operators: X, .., …
  • Reduction operator
    • Example: factorial
    • Example: using a function
    • Example: matrices
  • Operators and syntax elements
    • Multiplication operator
    • Exponentiation operator
    • Regex repetition quantifier
    • Min–max repetitions
  • Slurpy arguments
    • Slurpy-slurpy
  • Twigils and dynamic scope
  • Compiler variables
  • Methods named “this”
  • Whatever
  • WhateverCode
  • Homework
  • Additional assignments
  • EVAL routine

Raku Golf

  • First test
  • Second test
  • Tips and techniques
    • Omitting semicolons
    • Omitting topic variable
    • Using postfix forms
    • Using ranges for loops
    • Choosing between range and sequence
    • Using map instead of loops
    • Omitting parentheses and quotes
    • Chained comparisons
    • Choosing between methods and functions
    • Using Unicode characters
    • Superscripts
    • Using \ for sigilless variables
    • Default parameters
    • Using && instead of if
    • Choosing between put and say

Book Description

“Raku One-Liners” by Andrew Shitov is like a treasure chest for programmers who crave efficiency. This PDF brings you an amazing collection of short, punchy Raku scripts that solve real problems. Whether you’re a total newbie or a seasoned coder, you’ll find these one-liners both practical and inspiring. Who doesn’t love saving time with a clever shortcut?

Book Overview

This book isn’t your typical dry programming manual. Instead, it jumps right into the fun stuffcode that actually does something cool! Each page offers bite-sized examples demonstrating Raku’s flexibility and expressive power. The author keeps things light and approachable, so you won’t feel overwhelmed. If you’ve ever looked at a wall of code and thought, “There must be a simpler way,” this book’s for you.

Why Read This Book

In this book, you will find a number of short programs that you may want to use in your daily practice. You will also find a number of one-line snippets that can enter into your bigger programs.

The goal of the book is not to give a copy-and-paste list of coding examples, but to explain the various bits of Raku that help to use the language more efficiently. To run the program examples from the rest of the book, you need to download and install the most recent Rakudo Star compiler pack from its website, rakudo.org.

If you are using the previous, Perl 6-based compiler, create an alias in your .profile file so that you can use the raku command to run the compiler: alias raku=perl6

Who This Book Is For

If you’re curious about Raku or already love Perl, this book will speak your language. It’s great for developers who want to write smarter, not harder. Maybe you’ve got a project that needs quick fixes, or maybe you’re just addicted to clever code tricks (hey, we all have our vices). Students, hobbyists, and pros alike will find value here.

What You Will Learn

  • How to write concise Raku code that actually works in the real world
  • Creative solutions to common programming challenges using one-liners
  • The basics of Raku syntax without getting bogged down in details
  • Tons of tips for making your scripts more efficient (and fun!)
  • How to approach problems from different anglesbecause sometimes thinking outside the box pays off
  • Ways to automate boring tasks so you can get back to the interesting stuff

Book Details


Length: 93 Pages

Language: English

PDF Size: 0.76 Mbs

Category: 

Report Broken Link

File Copyright Claim

Comments

Leave a Reply

Categories

Related Posts

Split List into Columns
PDF Viewer

Please wait while the PDF is loading...
📘 Download PDF Book