Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.47 KB | None | 0 0
  1.  
  2.     def product( str: String) = {
  3.         /* calculate product of the unicode codes of all letters
  4.         in a string. F.e. "Hello"  is 825152896 */
  5.         var result : BigInt = 1
  6.         for(c <- str)  result = result * c
  7.        
  8.         result
  9.     }
  10.  
  11.     def product1 (str: String) = {
  12.         /* Writing product function without cycles */
  13.         var result : BigInt = 1
  14.         str.foreach(result *= _)
  15.         //println(result)
  16.  
  17.         result
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement