Functional Programming Questions

Functional programming as a paradigm and a way of structuring code: pure functions and side-effect isolation (a pure core with effects at the edges, and how effects are described versus run), immutability and persistent data structures with structural sharing, updating nested immutable data including lenses, higher-order functions, function composition, currying and partial application, folds and recursion over data (including tail recursion), algebraic data types and pattern matching, total functions and Maybe/Either style error values, functors, applicatives and monads as patterns for composing effects and threading state, parser combinators as a worked example, lazy evaluation and lazy or streaming pipelines, and property-based testing of pure code. Covers reasoning about programs as composed transformations rather than mutable state, in a dedicated functional language such as Haskell or Scala, or in a multi-paradigm language such as JavaScript, TypeScript, Kotlin or Python. Boundary: closures and the this binding as language mechanics, the event loop and reactive streams, threads and STM-style concurrency, performance profiling, and exception or resource handling are covered elsewhere.

EasyTechnical
73 practiced

How does property-based testing differ from example-based testing? Write a property for 'reversing a list twice gives back the original' in a tool you know (QuickCheck, fast-check, Hypothesis), explain how inputs are generated and how a failing case is shrunk, and name one limitation.

MediumTechnical
91 practiced

You must transform a multi-gigabyte file of line-delimited records, parsing each, dropping invalid ones and writing JSON out, in constant memory. Design the pipeline using lazy or streaming constructs (generators, iterators, lazy sequences or a streaming library). Why does it avoid the memory blowup of reading everything first, and what breaks that property?

HardTechnical
88 practiced

You inherit a service where almost every business rule is tangled with database calls, HTTP requests and logging. How would you move it toward a pure core with effects at the edges? Walk through the incremental migration, how you would test the extracted logic, and when you would stop short of heavier abstractions.

EasyTechnical
140 practiced

A function can fail. Compare returning an optional value, returning a result that carries an error, and throwing. When would you reach for a Result/Either type over Option/Maybe, and how do callers combine several such calls without nested null or error checks? Show a small example in a language you know.

HardTechnical
99 practiced

Copying a large map on every update to keep it immutable would be far too slow, yet libraries like Immutable.js and Clojure's collections do it cheaply. Explain how a persistent map can give you a new version while sharing most of its memory with the old one, what that costs per operation, and whether you would build one yourself or adopt a library in a production app.

Unlock Full Question Bank

Get access to all 6 Functional Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.