Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

1

Building on JanDotNet's answer, I've revised my code, and the result is as below. I have both rethought the algorithms and the overall design and flow. Especially the validation of input is changed to use the Result<'T,'TError> type - and (I hope) conforms to the "railway" pattern. One difference to JanDotNet's is that I return a roman numeral only if ...


1

General I think the correct translation is Roman numeral. As far as I understood, it is not a good functional style to throw exceptions in case of unexpected input because it breaks the purity. An alternative approach is Railway oriented programming which makes the code much cleaner and separates the business logic from the exception handling. Internal ...


1

I think you need an id field to be sure that you're updating the correct combatant. I assume it's possible to have multiple combatants with the same hp and attack. And in that case it makes sense to store a group as a Map of id to combatant. This makes it really simple to update a value by id and there's no need to check for existence first. See the ...


3

You should reduce the use of explicit type declaration as much as possible. A function isn't of much value if it just prints its calculated result. You should return the result to let it be up to the client to handle it. But you can't break out from a loop via an if-statement in F#. You can overcome that by wrapping the outer for-loop in a seq {...} ...


Top 50 recent answers are included