Book description
Want to learn how to program and think like a computer scientist? This practical guide gets you started on your programming journey with the help of Perl 6, the younger sister of the popular Perl programming language. Ideal for beginners, this hands-on book includes over 100 exercises with multiple solutions, and more than 1,000 code examples so you can quickly practice what you learn. Experienced programmers—especially those who know Perl 5—will also benefit.
Divided into two parts, Think Perl 6 starts with basic concepts that every programmer needs to know, and then focuses on different programming paradigms and some more advanced programming techniques. With two semesters’ worth of lessons, this book is the perfect teaching tool for computer science beginners in colleges and universities.
- Learn basic concepts including variables, expressions, statements, functions, conditionals, recursion, and loops
- Understand commonly used basic data structures and the most useful algorithms
- Dive into object-oriented programming, and learn how to construct your own types and methods to extend the language
- Use grammars and regular expressions to analyze textual content
- Explore how functional programming can help you make your code simpler and more expressive
Publisher resources
Table of contents
- Preface
- I. Starting with the Basics
- 1. The Way of the Program
- 2. Variables, Expressions, and Statements
-
3. Functions
- Function Calls
- Functions and Methods
- Math Functions
- Composition
- Adding New Functions (a.k.a. Subroutines)
- Definitions and Uses
- Flow of Execution
- Parameters and Arguments
- Variables and Parameters Are Local
- Stack Diagrams
- Fruitful Functions and Void Functions
- Function Signatures
- Immutable and Mutable Parameters
- Functions and Subroutines as First-Class Citizens
- Why Functions and Subroutines?
- Debugging
- Glossary
- Exercises
-
4. Loops, Conditionals, and Recursion
- Integer Division and Modulo
- Boolean expressions
- Logical Operators
- Conditional Execution
- Alternative Execution
- Chained Conditionals
- Nested Conditionals
- if Conditionals as Statement Modifiers
- Unless Conditional Statement
- for Loops
- Recursion
- Stack Diagrams for Recursive Subroutines
- Infinite Recursion
- Keyboard Input
- Program Arguments and the MAIN Subroutine
- Debugging
- Glossary
- Exercises
- 5. Fruitful Subroutines
- 6. Iteration
- 7. Strings
- 8. Case Study: Word Play
-
9. Arrays and Lists
- Lists and Arrays Are Sequences
- Arrays Are Mutable
- Adding New Elements to an Array or Removing Some
- Stacks and Queues
- Other Ways to Modify an Array
- Traversing a List
- New Looping Constructs
- Map, Filter, and Reduce
- Fixed-Size, Typed, and Shaped Arrays
- Multidimensional Arrays
- Sorting Arrays or Lists
- More Advanced Sorting Techniques
- Debugging
- Glossary
- Exercises
- 10. Hashes
-
11. Case Study: Data Structure Selection
- The Ternary Conditional Operator
- The given ... when “Switch” Statement
- Subroutine Named and Optional Parameters
- Word Frequency Analysis
- Random Numbers
- Word Histogram
- Most Common Words
- Optional Parameters
- Hash Subtraction
- Constructing New Operators
- Sets, Bags, and Mixes
- Random Words
- Markov Analysis
- Data Structures
- Building Your Own Data Structures
- Debugging
- Glossary
- Exercises: Huffman Coding
- II. Moving Forward
-
12. Classes and Objects
- Objects, Methods, and Object-Oriented Programming
- Programmer-Defined Types
- Attributes
- Creating Methods
- Rectangles and Object Composition
- Instances as Return Values
- Inheritance
- Roles and Composition
- Method Delegation
- Polymorphism
- Encapsulation
- Interface and Implementation
- Object-Oriented Programming: A Tale
- Debugging
- Glossary
- 13. Regexes and Grammars
- 14. Functional Programming in Perl
- 15. Some Final Advice
-
A. Solutions to the Exercises
- Exercises of Chapter 3: Functions and Subroutines
- Exercises of Chapter 4: Conditionals and Recursion
- Exercises of Chapter 5: Fruitful Functions
- Exercises of Chapter 6: Iteration
- Exercises of Chapter 7: Strings
- Exercises of Chapter 8: Word Play
-
Exercises of Chapter 9: Arrays and Lists
- Exercise: Implementing a Queue
- Exercise: Other Ways to Modify an Array
- Exercise: Mapping and Filtering the Elements of a List
- Exercise: Advanced Sorting Techniques
- Exercise 9-1: Nested Sum
- Exercise 9-2: Cumulative Sum
- Exercise 9-3: Middle
- Exercise 9-4: Chop
- Exercise 9-5: Subroutine is-sorted
- Exercise 9-6: Subroutine is-anagram
- Exercise 9-7: Subroutine has-duplicates
- Exercise 9-8: Simulating the Birthday Paradox
- Exercise 9-9: Comparing push and unshift
- Exercise 9-10: Bisection Search in a List
- Exercise 9-11: Reverse Pairs
- Exercise 9-12: Interlocking Words
- Exercises of Chapter 10: Hashes
- Exercises of Chapter 11
- Exercises of Chapter 13: Regexes and Grammars
- Exercises of Chapter 14: Functional Programming
- Index
Product information
- Title: Think Perl 6
- Author(s):
- Release date: May 2017
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781491980507
You might also like
book
Learning Perl 6
f you’re ready to get started with Raku (formerly Perl 6), this is the book you …
book
Minimal Perl
Perl is a complex language that can be difficult to master. Perl advocates boast that "There's …
book
Perl 6 Deep Dive
Learn Perl 6 effortlessly to solve everyday problems About This Book Filled with practical examples, this …
book
Beginning Perl
Everything beginners need to start programming with Perl Perl is the ever-popular, flexible, open source programming …