SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top