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++ - Another nice talk about constexpr with tuple less than 1 minute read This is an excellent talk discussing tuples in the context of constexpr. It is highly recommended for anyone seeking a deeper understanding of constexpr in C...
PyTorch - Basic but contains most of useful information less than 1 minute read The following article explain the basic introduction of PyTorch.
C++ - Deducing this feature 1 minute read C++23 introducing a new feature called deducing this. This is solving the following issues.