#functional

25 snippets tagged with #functional

pythonintermediate

Python Itertools Recipes

Practical itertools patterns for batching, flattening, grouping, and combining iterables.

Best for: Efficient batch processing of large datasets

#python#itertools
javabeginner

Java Streams — Filter, Map, Collect

Process collections with Java Streams: filter, map, flatMap, reduce, and collect to lists or maps.

Best for: Transforming and filtering collections

#java#streams
javaintermediate

Strategy Pattern with Lambdas

Implement the Strategy pattern using interfaces and Java lambdas for flexible algorithm selection.

Best for: Swappable pricing or discount algorithms

#java#design-patterns
javaadvanced

Advanced Streams — Custom Collectors

Advanced Stream operations: custom collectors, flatMap, reduce, teeing, and parallel streams.

Best for: Complex data aggregation and reporting

#java#streams
javaintermediate

Functional Interfaces and Lambda Patterns

Use built-in and custom functional interfaces: Predicate, Function, Consumer, Supplier, and composition.

Best for: Composable validation and filtering logic

#java#functional
javabeginner

Method References — All Four Types

Use method references for concise lambda expressions: static, instance, arbitrary object, and constructor.

Best for: Concise functional-style code with method references

#java#method-reference
javaintermediate

Decorator Pattern — OOP and Functional

Implement the decorator pattern both classically and with functional composition for flexible behavior.

Best for: Adding behavior to objects without subclassing

#java#decorator
javaintermediate

Stream MapReduce and Aggregation

Use streams for MapReduce-style operations: reduce, collect, summarize, and complex aggregations.

Best for: Sales data aggregation and reporting

#java#streams
javaintermediate

Checked Exception Wrapping Utilities

Wrap checked exceptions for use in lambdas and streams: sneaky throws, functional wrappers, and Either.

Best for: Using checked-exception methods in lambda expressions

#java#exceptions
kotlinbeginner

Collections — map, filter, groupBy, and More

Master Kotlin collections: functional transformations, aggregations, grouping, and partition operations.

Best for: Data processing and transformation pipelines

#kotlin#collections
kotlinintermediate

Result Monad — Functional Error Handling

Handle errors functionally with Kotlin Result: map, recover, fold, and chaining fallible operations.

Best for: Type-safe error handling without exceptions

#kotlin#result
kotlinintermediate

Higher-Order Functions and Lambda Patterns

Compose behavior with higher-order functions: function types, lambda receivers, and functional composition.

Best for: Composable transformation pipelines

#kotlin#functional
kotlinadvanced

Functional Error Handling with Either

Use Either and Option for type-safe error handling: Railway-oriented programming without exceptions.

Best for: Type-safe error handling without exceptions

#kotlin#functional
kotlinadvanced

Functional Error Handling with Either

Implement Either monad for type-safe error handling with map, flatMap, and fold operations.

Best for: Type-safe error handling without exceptions

#kotlin#functional
kotlinbeginner

Collection Transformations and Aggregations

Master Kotlin collection operations: groupBy, partition, associate, zip, windowed, and aggregate.

Best for: Data aggregation and reporting

#kotlin#collections
kotlinintermediate

Kotlin Result API Functional Error Handling

Use Kotlin's built-in Result type for functional error handling: runCatching, map, recover, and fold.

Best for: Functional error handling without try-catch

#kotlin#result
kotlinintermediate

Functional Composition and Pipelines

Compose functions and build transformation pipelines with Kotlin higher-order functions.

Best for: Data transformation pipelines

#kotlin#functional
scalabeginner

Collections Map Filter Fold Operations

Master Scala collections: map, flatMap, filter, fold, groupBy, partition, and zip operations.

Best for: Data transformation and aggregation

#scala#collections
scalaintermediate

For-Comprehensions and Monadic Composition

Use for-comprehensions with Option, Either, Future, and custom monads for elegant composition.

Best for: Chaining optional computations

#scala#for-comprehension
scalaadvanced

Type Class Pattern Implementation

Implement the type class pattern in Scala 3: define, provide instances, and use with extension methods.

Best for: Ad-hoc polymorphism without inheritance

#scala#type-class
scalaadvanced

Cats Effect IO Monad Basics

Use Cats Effect IO for pure functional effects: sequencing, error handling, resource management.

Best for: Pure functional effect management

#scala#cats-effect
scalaadvanced

ZIO Effect System Basics

Build programs with ZIO: effects, error handling, layers, and concurrent operations.

Best for: Typed error handling with ZIO

#scala#zio
scalaadvanced

Cats Monad Transformers

Use Cats monad transformers: EitherT, OptionT, and StateT for composable effect stacks.

Best for: Composable error handling stacks

#scala#cats
scalaadvanced

Streaming with fs2

Build composable streaming pipelines with fs2: chunks, transformations, concurrency, and resource safety.

Best for: Streaming data processing

#scala#fs2
scalaintermediate

Functional State Management

Manage state purely with State monad: stack-based state, random number generation, and game state.

Best for: Pure state transformations

#scala#state