Computer ScienceTextbook

Think Raku: How to Think Like a Computer Scientist

Not rated yetRate this book

About this book Laurent Rosenfeld’s Think Raku, with Allen B. Downey, teaches programming and problem solving through the Raku language. The linked second edition is Version 0.6, January 2020. Fifteen…

FormatExternal access
LanguageEnglish
SubjectComputer Science
LevelUndergraduate
No. of pages431
Published2020

Free reading is available at the official source. Opens in a new tab.

Cover of Think Raku: How to Think Like a Computer ScientistFree

About this book

About this book

Laurent Rosenfeld’s Think Raku, with Allen B. Downey, teaches programming and problem solving through the Raku language. The linked second edition is Version 0.6, January 2020. Fifteen chapters develop basic execution, variables, functions, control flow, collections, objects, grammars, functional approaches, and maintainable program design. The complete 431-page PDF also provides exercise solutions. This guide follows that edition’s chapter structure and uses its title-page cover rather than the older Think Perl 6 cover used by some catalogs. The central learning method is to predict, implement, observe, debug, and explain increasingly structured programs.

Use the chapter guide and study instructions below alongside the complete text. Attempt the suggested practice independently, check your reasoning against the source, and revisit topics identified by the reflection questions.

Cover: original author or publisher material for book identification. Book details and source.

Book summary

Chapter-by-chapter study guide

Chapter 1: The Way of the Program

Programming combines decomposition, precise expression, experimentation, and debugging. The chapter introduces how programs are executed and the kinds of errors a learner must distinguish. Describe the intended behavior before writing code, then compare it with actual output. A syntax error, a failure during execution, and a program that runs but computes the wrong result require different kinds of investigation and should not be treated as one vague problem.

Chapter 2: Variables, Expressions, and Statements

Variables name values, expressions compute results, and statements organize actions. The chapter builds a vocabulary for reasoning about state and evaluation. Trace a short program one line at a time, recording the value and type you expect at each stage. A printed representation and the underlying value are not always the same thing. Clear names and explicit expectations make later debugging much easier.

Chapter 3: Functions

Functions or subroutines organize a computation behind a named interface. Parameters, arguments, local reasoning, and repeated use help divide a larger problem into manageable parts. Write down what a subroutine requires and what it does before implementing it. Compare calling a function with defining it, and trace how information enters and leaves. A useful abstraction reduces the details a caller must understand without making the behavior mysterious.

Chapter 4: Loops, Conditionals, and Recursion

Conditional execution changes a program’s path, while repetition and recursion express recurring work. The chapter connects conditions and control with the state of a computation. Trace both outcomes of a condition and identify the case that stops a recursive process. A correct example for one input is not enough: test boundary conditions and explain why each execution path reaches an appropriate result rather than continuing indefinitely.

Chapter 5: Fruitful Subroutines

Returning a value allows a subroutine’s result to participate in larger expressions and programs. The chapter distinguishes returned results from side effects such as printing. Replace a display-only routine with one that returns a value and show how another function can use it. Incremental development and small checks help isolate errors. The interface should make the function’s purpose clear without requiring every caller to inspect its internal implementation.

Chapter 6: Iteration

Iteration provides systematic ways to repeat a process and update a result. The chapter connects loops with algorithms whose progress can be traced and justified. Identify initialization, the repeated operation, the condition for continuation, and termination. Compare a loop with a recursive formulation of the same task. The important question is not which notation is shorter but which makes correctness, stopping conditions, and the state changes easier to understand.

Chapter 7: Strings

Strings are ordered sequences whose elements and patterns can be examined and transformed. The chapter develops operations beyond treating text as an indivisible value. Trace indexing, traversal, and pattern-related examples carefully, including empty or unexpected inputs. Explain the distinction between a position, a character, and a portion of the string. A text-processing program should state what kinds of input it expects rather than assuming that every example looks like a simple word.

Chapter 8: Word Play

The case study consolidates earlier concepts through problems involving words and text. Its value lies in translating a verbal condition into a clear algorithm and checking the interpretation. Write a few examples that should pass and fail before coding. Separate reading data, evaluating a condition, and reporting a result. When an answer looks plausible, verify it against a smaller dataset whose correct result can be established independently.

Chapter 9: Arrays and Lists

Collections allow a program to organize multiple values, but their behavior must be understood rather than inferred from their appearance. The chapter develops sequence operations and the distinction between relevant collection forms. Draw the data structure and trace how an operation changes or produces it. Test an empty collection, one element, and repeated values. Those cases often expose assumptions hidden by a longer, more varied example.

Chapter 10: Hashes

Hashes associate keys with values and support problems involving lookup, counting, and relationships. The chapter shows how choosing a different representation can simplify a computation. Compare searching a sequence with consulting a key-based structure and explain the purpose of the key. Consider missing keys and repeated updates explicitly. A hash is useful because of how it represents the problem, not because every collection should be converted into one.

Chapter 11: Data Structure Selection

The second case study asks readers to choose among the structures and algorithms developed earlier. A good choice depends on the operations required, the input, and the clarity of the resulting design. Compare two representations for the same task and identify what becomes easier or harder in each. Separate a compact expression from an efficient or understandable algorithm; brevity alone does not settle the choice.

Chapter 12: Classes and Objects

Classes create programmer-defined types that connect data and operations. The chapter introduces abstraction and encapsulation as ways to manage complexity. Describe the responsibility of an object and the operations through which other code should use it. Distinguish class definitions from individual instances and keep internal state consistent. An object-oriented design is useful when its boundaries explain the problem rather than merely adding a class around unrelated functions.

Chapter 13: Regexes and Grammars

Pattern matching grows into structured recognition and parsing. The chapter revisits regex concepts before developing richer ways to describe text. Compare finding a matching fragment with validating the structure of an entire input. Test examples that almost satisfy the pattern and explain where they fail. A grammar should communicate the structure being recognized, while later processing determines what meaning or result is constructed from it.

Chapter 14: Functional Programming

Functional approaches emphasize transformations and relationships between inputs and outputs while limiting unnecessary mutable state. The chapter introduces techniques that can make behavior easier to compose and reason about. Compare an explicit update loop with a transformation pipeline and explain each intermediate value. Readability still matters: a sophisticated expression should clarify the computation, and the learner should be able to describe it without relying on its compact appearance.

Chapter 15: Final Advice

The closing chapter returns to simplicity, clarity, debugging, and maintainability. Learning an advanced feature does not create an obligation to use it everywhere. Review an earlier program and identify changes that make its intent clearer, its parts easier to test, or its assumptions more visible. Explain the benefit of each change. Good programming includes choosing what to leave straightforward, especially when someone else must read or modify the result.

Exercise Solutions

The solution section supports comparison after an independent attempt. Read for design decisions and reasoning rather than copying a finished program. Identify where your approach differs, whether both satisfy the stated problem, and which handles boundary cases more clearly. Reimplement a similar problem without looking at either version. The goal is transferable problem-solving ability, not familiarity with the appearance of one published answer.

Study instructions

Work through the chapters sequentially and keep small, runnable programs for each concept. Predict the output before execution, then explain any difference. Develop an example in short steps and retain simple checks that would reveal a regression in behavior. For each exercise, write the input, required output, examples, boundary cases, and proposed algorithm before implementation. Use the solutions only after a serious attempt, and compare reasoning rather than merely matching output. Keep a debugging journal distinguishing syntax, execution, and logic errors. The book describes a January 2020 language snapshot; use the course’s chosen environment and consult current official Raku documentation when a compatibility question arises. Finish with a modest text-processing project whose data structures, functions, error handling, and user-facing behavior you can explain clearly.

Questions for reflection

  • How does returning a value differ from printing it?
  • What establishes that a loop or recursive process will terminate?
  • When does a hash represent a problem better than a sequence?
  • How can a shorter program be harder to maintain?

Sources and coverage

Coverage follows all fifteen chapters and the exercise solutions in the January 2020 second edition, Version 0.6. Examples are discussed as learning material from that edition rather than a guarantee of current environment compatibility.

This is an AI-assisted original, condensed study guide based on the source contents, chapter introductions, and selected explanations, examples, and review activities. It is not a page-by-page substitute for the book, and no human or expert review is claimed.

Official book record · Reviewed full text

About access & copyright

This page provides book information and study material. Full-text access is provided by the original publisher or authorised source; a listing does not grant permission to republish the book.

Read our Library Access & Copyright policy

Explore the contents

Check the chapters covered in this edition.

Visit the official source

See reading, preview or purchase options.

Save for later

Keep this textbook in your saved collection.

Reader ratings & reviews

Be the first to rate

No ratings yet

0%0%
0%0%
0%0%
0%0%
0%0%

Share your thoughts

Your review helps other students choose the right resources.

Rate this book

How helpful was this book?No sign-up needed. Your rating appears instantly.