Cargando…

Functional Python programming : use a functional approach to write succinct, expressive, and efficient Python code /

Python isn't all about object-oriented programming. Discover a valuable way of thinking about code design through a function-first approach - and learn when you need to use it. Now with detailed exercises at the end of every chapter! Purchase of the print or Kindle book includes a free eBook in...

Descripción completa

Detalles Bibliográficos
Clasificación:Libro Electrónico
Autor principal: Lott, Steven F. (Autor)
Otros Autores: Bánffy, Ricardo (writer of foreword.)
Formato: Electrónico eBook
Idioma:Inglés
Publicado: Birmingham : Packt Publishing, [2022]
Edición:Third edition.
Colección:Expert insight.
Temas:
Acceso en línea:Texto completo
Tabla de Contenidos:
  • Cover
  • Copyright
  • Contributors
  • Table of Contents
  • Preface
  • Chapter 1: Understanding Functional Programming
  • The functional style of programming
  • Comparing and contrasting procedural and functional styles
  • Using the functional paradigm
  • Using a functional hybrid
  • The stack of turtles
  • A classic example of functional programming
  • Exploratory data analysis
  • Summary
  • Exercises
  • Convert an imperative algorithm to functional code
  • Convert step-wise computation to functional code
  • Revise the sqrt() function
  • Data cleansing steps
  • (Advanced) Optimize this functional code
  • Chapter 2: Introducing Essential Functional Concepts
  • Functions as first-class objects
  • Pure functions
  • Higher-order functions
  • Immutable data
  • Strict and non-strict evaluation
  • Lazy and eager evaluation
  • Recursion instead of an explicit loop state
  • Functional type systems
  • Familiar territory
  • Learning some advanced concepts
  • Summary
  • Exercises
  • Apply map() to a sequence of values
  • Function vs. lambda design question
  • Optimize a recursion
  • Chapter 3: Functions, Iterators, and Generators
  • Writing pure functions
  • Functions as first-class objects
  • Using strings
  • Using tuples and named tuples
  • Using generator expressions
  • Exploring the limitations of generators
  • Combining generator expressions
  • Cleaning raw data with generator functions
  • Applying generators to built-in collections
  • Generators for lists, dicts, and sets
  • Using stateful mappings
  • Using the bisect module to create a mapping
  • Using stateful sets
  • Summary
  • Exercises
  • Rewrite the some_function() function
  • Alternative Mersenne class definition
  • Alternative algorithm implementations
  • Map and filter
  • Dictionary comprehension
  • Raw data cleanup
  • Chapter 4: Working with Collections
  • An overview of function varieties
  • Working with iterables
  • Parsing an XML file
  • Parsing a file at a higher level
  • Pairing up items from a sequence
  • Using the iter() function explicitly
  • Extending an iteration
  • Applying generator expressions to scalar functions
  • Using any() and all() as reductions
  • Using len() and sum() on collections
  • Using sums and counts for statistics
  • Using zip() to structure and flatten sequences
  • Unzipping a zipped sequence
  • Flattening sequences
  • Structuring flat sequences
  • Structuring flat sequences
  • an alternative approach
  • Using sorted() and reversed() to change the order
  • Using enumerate() to include a sequence number
  • Summary
  • Exercises
  • Palindromic numbers
  • Hands of cards
  • Replace legs() with pairwise()
  • Chapter 5: Higher-Order Functions
  • Using max() and min() to find extrema
  • Using Python lambda forms
  • Lambdas and the lambda calculus
  • Using the map() function to apply a function to a collection
  • Working with lambda forms and map()
  • Using map() with multiple sequences