Scala - conversion from for-comprehension to map, flatMap less than 1 minute read 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def getProduct(id: String): Try[Product] def getPrice(product: Product): Try[Price] def calculateProductPrice(product: Product, price: Price): Try[Price] for { product <- getProduct("1234") price <- getPrice(product) calculatedPrice <- calculateProductPrice(product, price) if (calculatedPrice > 1000) } yield (product, calculatedPrice) getProduct("1234").flatMap{ product => getPrice(product).flatMap{ price => calculateProductPrice(product, price).filter { p => p > 1000 } .map{ p => (product, p) } } } Share on Twitter Facebook LinkedIn Previous Next
C++ - std::piecewise_constructor to avoid temporary object creation less than 1 minute read Streamlining C++ Code - Avoiding Unnecessary C++ Object Creation - C++Now 2025
How to create MCP server with TypeScript less than 1 minute read The Ultimate MCP Crash Course - Build From Scratch
C++ custom view for ranges 2 minute read The following youtube shows a good explanation how we can define the custom view for ranges
How neural network works less than 1 minute read The following Youtube will explain all details from derivatives to building neural networks in scratch including how back propagation is working. If anyone i...