Hot answers tagged

14

Some suggestions to improve your code: xs.sortWith((e1, e2) => (e1 < e2)) is identical to xs.sorted If you are not interested in Stem.word you can place it into companions' apply-method: object Stem { def apply(word: String): Stem = { val stem: List[Char] = word.toLowerCase.trim.toList.sorted new Stem(stem) } } case class Stem private(...


4

I've been thinking about this question literally for weeks. It always seemed like this implementation suffers from "hammer syndrome" - if you have a really good hammer, you want to think every problem is a nail. Functional coding is a great tool for many things, but in this case, it has a problem. The reason why algorithms use mutable rather than immutable ...


3

First thoughts: If an operation can fail, it is generally good practise to make this explicit in the API by returning a Try instead of an Either. The duplicate code seems to stem from the fact that Money operations are only valid on Currencies of the same type. Scala gives you the power to have this check at compile time. Example Code: object Money { ...


2

I think you did a pretty good job overall. You can simplify your code by making CounterService.make not return an effect since you only call ZIO.succeed in it. make can return directly a CounterService and that way no need to call unsafeRun in your main app. I also think that the HttpRoutes class is not really necessary since it only has a single method ...


1

Looks good to me. Although, having cache as a simple Map might lay claim to more memory that you like. Associating an LRU with it would allow each addition to evict an ancient job's cached dataframe.


Only top voted, non community-wiki answers of a minimum length are eligible