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.

MediumTechnical
68 practiced

You have a function that increments a counter held in a global or an IORef-style mutable cell. Refactor it so the state is passed through explicitly and returned, for example with a State monad or a reducer. Show how to run it from a given initial value, and explain what you gained.

EasyTechnical
73 practiced

Without using the built-in map, implement map for a list or array by hand. Then explain how it composes with filter and reduce in a pipeline, and one downside of your hand-rolled version compared with the library one.

EasyTechnical
73 practiced

What is a pure function, and what does immutability buy you? Take one small piece of code that mutates shared state and show how you would rewrite it as pure functions over immutable data. Where does that change help with testing, reasoning about the code, and running it concurrently, and where does it cost you?

MediumTechnical
92 practiced

You have a deeply nested settings object that must be updated immutably, for example changing one field three levels down while sharing the rest. Show how to do it by hand. Then explain what a lens (getter/setter pair) is and how composing lenses makes this reusable, and when it is overkill.

MediumTechnical
82 practiced

Your team is debating whether a small UI widget that keeps a counter and re-renders a view should be written with classes and mutable fields or as plain functions over immutable state. Sketch both versions in JavaScript or TypeScript, then tell me which you would ship and what you would give up by choosing it.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.