Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def product( str: String) = {
- /* calculate product of the unicode codes of all letters
- in a string. F.e. "Hello" is 825152896 */
- var result : BigInt = 1
- for(c <- str) result = result * c
- result
- }
- def product1 (str: String) = {
- /* Writing product function without cycles */
- var result : BigInt = 1
- str.foreach(result *= _)
- //println(result)
- result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement