Racket Programming the Fun Way: From Strings to Turing Machines

Racket Programming the Fun Way: From Strings to Turing Machines

by James. W. Stelly
Racket Programming the Fun Way: From Strings to Turing Machines

Racket Programming the Fun Way: From Strings to Turing Machines

by James. W. Stelly

Paperback

$49.95 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores

Related collections and offers


Overview

An introduction to the Racket functional programming language and DrRacket development environment to explore topics in mathematics (mostly recreational) and computer science.

At last, a lively guided tour through all the features, functions, and applications of the Racket programming language. You'll learn a variety of coding paradigms, including iterative, object oriented, and logic programming; create interactive graphics, draw diagrams, and solve puzzles as you explore Racket through fun computer science topics--from statistical analysis to search algorithms, the Turing machine, and more.

Early chapters cover basic Racket concepts like data types, syntax, variables, strings, and formatted output. You'll learn how to perform math in Racket's rich numerical environment, and use programming constructs in different problem domains (like coding solutions to the Tower of Hanoi puzzle). Later, you'll play with plotting, grapple with graphics, and visualize data. Then, you'll escape the confines of the command line to produce animations, interactive games, and a card trick program that'll dazzle your friends.

You'll learn how to:
  • Use DrRacket, an interactive development environment (IDE) for writing programs
  • Compute classical math problems, like the Fibonacci sequence
  • Generate two-dimensional function plots and create drawings using graphics primitives
  • Import and export data to and from Racket using ports, then visually analyze it
  • Build simple computing devices (pushdown automaton, Turing machine, and so on) that perform tasks
  • Leverage Racket's built-in libraries to develop a command line algebraic calculator

  • Racket Programming the Fun Way is just like the language itself--an embodiment of everything that makes programming interesting and worthwhile, and that makes you a better programmer.

    Product Details

    ISBN-13: 9781718500822
    Publisher: No Starch Press
    Publication date: 01/08/2021
    Pages: 360
    Sales rank: 1,049,691
    Product dimensions: 7.00(w) x 9.20(h) x 1.10(d)

    About the Author

    James W. Stelly is a semiretired systems analyst and developer of several business-line applications utilizing backend databases. He has degrees in mathematics and computer science from the University of Houston, and this book is a result of his lifelong interest in those topics.

    Table of Contents

    Acknowledgments xvii

    Introduction xix

    1 Racket Basics 1

    Atomic Data 1

    Lists 2

    A First Look at Lists 2

    S-Expressions 3

    List Structure 4

    A Few Useful List Functions 6

    Defines, Assigns, and Variables 8

    Symbols, Identifiers, and Keywords 10

    Equality 11

    Strings and Things 12

    Characters 12

    Useful String Functions 14

    String Conversion and Formatting Functions 17

    Vectors 18

    Accessing Victor Elements 19

    Useful Vector Functions 20

    Using structs 21

    Controlling Output 24

    Summary 26

    2 Arithmetic and Other Numerical Paraphernalia 27

    Booleans 27

    The Numerical Tower 29

    Integers 29

    Rationals 30

    Reals 31

    Complex Numbers 32

    Numeric Comparison 33

    Combining Data Types 34

    Built-in Functions 36

    Infix Notation 37

    Summary 39

    3 Function Fundamentals 41

    What Is a Function? 41

    Lambda Functions 42

    Higher-Order Functions 43

    Lexical Scoping 45

    Conditional Expressions: It's All About Choices 47

    I'm Feeling a Bit Loopy! 48

    Purity 49

    The Power of the Dark Side 51

    The for Family 52

    Time for Some Closure 58

    Applications 60

    I Don't Have a Queue 60

    The Tower of Hanoi 64

    Fibonacci and Friends 66

    The Insurance Salesman Problem 72

    Summary 74

    4 Plotting, Drawing, and a Bit of Set Theory 75

    Plotting 75

    X-Y Plots 76

    Parametric Plots 79

    Getting to the Point 86

    Polar Plots 88

    Drawing 92

    Set Theory 96

    The Basics 96

    A Short Mathematical Detour 100

    Drawing Conclusions 101

    Are We Related? 103

    Applications 105

    Fibonacci Revisited 105

    Nim 109

    Summary 115

    5 GUI: Getting Users Interested 117

    Introduction to GUIs 118

    Animating a Cycloid 121

    Pick a Card 124

    GUI Layout 127

    Building the Controls 128

    Control Logic 130

    Linear Algebra Zone 130

    Wrapping Up the GUI 131

    Control Tower 133

    Setting Up 133

    Row 1 Widgets 135

    Row 2 Widgets 137

    Getting in Position 138

    Controlling the Animation 140

    Wrapping Things Up 143

    Summary 144

    6 DATA 145

    I/O, I/O, It's Off to Work We Go 145

    File I/O Ports 145

    String Ports 147

    Computer-to-Computer Ports 148

    Introduction to Security 149

    Getting Data into Racket 150

    A Database Detour 155

    Data Visualization 159

    Plotting for Success 161

    Lumping Things Together 167

    A Bit of Statistics 171

    Standard Deviation 171

    Regression 173

    Summary 178

    7 Searching For Answers 179

    Graph Theory 180

    The Basics 180

    Graph Search 182

    The N-Queens Problem 183

    A Racket Solution 185

    Dijkstra's Shortest Path Algorithm 189

    The Priority Queue 191

    The Implementation 194

    The 15 Puzzle 198

    The A* Search Algorithm 200

    The 8-Puzzte in Racket 204

    Moving Up to the 15 Puzzle 209

    Sudoku 215

    Summary 225

    8 Logic Programming 227

    Introduction 228

    The Basics 230

    Knowing Your Relatives 230

    Racklog Predicates 234

    Racklog Utilities 241

    Applications 245

    SEND + MORE = MONEY 245

    Fox, Goose, Beans 246

    How Many Donuts? 252

    Boles and Creots 254

    Summary 258

    9 Computing Machines 259

    Finite-State Automata 259

    The Turing Machine 263

    A Racket Turing Machine 265

    Pushdown Automata 267

    Recognizing Zeros and Ones 268

    More Zeros and Ones 269

    A Racket PDA 270

    More Automata Fun 272

    A Few Words About Languages 272

    Summary 273

    10 Trac: The Racket Algebraic Calculator 275

    The TRAC Pipeline 276

    The Lexical Analyzer 277

    Regular Expressions 279

    Regular Expressions in Racket 280

    Regular Expressions in TRAC 284

    The Lexer 286

    The Parser 288

    TRAC Grammar Specification 291

    The TRAC Parser 299

    TRAC 299

    Adding a Dictionary 301

    A Few Enhancements 309

    Making Sure TRAC Works Properly 314

    Making an Executable 315

    Summary 315

    A Number Bases 317

    B Special Symbols 321

    Bibliography 325

    Index 327

    From the B&N Reads Blog

    Customer Reviews