Open waij opened 7 years ago
def sumDigits(s:String):Int= s.map( c => c.asDigit ).sum
Wanted to let you know I appreciate all your comments and will (eventually) address them all. I've been working on another book for the last couple of years and have a couple of other projects piled up so it could be awhile. But I've noticed the activity and appreciate your contributions.
In the solution of exercise 1 of atom Design by Contract, you use foldLeft which you don't cover in your book (\<shouty mode/>: DON'T DO THAT!). I suggest using:
def sumDigits(s:String):Int= s.map( c => c.asDigit ).reduce( (result,i) => i + result)