| changeset 335 | 9476aee44eed | 
| parent 329 | 828326d1b3b2 | 
| child 353 | 0913158ef452 | 
| 334:305e1dcdb3bc | 335:9476aee44eed | 
|---|---|
471 test()  | 
471 test()  | 
472  | 
472  | 
473  | 
473  | 
474  | 
474  | 
475  | 
475  | 
476 ////////////  | 
|
477 // calculating pi  | 
|
478 def f(n: BigInt) = BigDecimal(4 * n * n) / BigDecimal(4 * n * n - 1)  | 
|
479  | 
|
480 2 * (BigInt(1) to BigInt(100000)).map(f).product  | 
|
481  | 
|
482 (1 to 1000).sum  | 
|
483 (1 to 1000).product  | 
|
484  | 
|
485  | 
|
476 // Further Information  | 
486 // Further Information  | 
477 //=====================  | 
487 //=====================  | 
478  | 
488  | 
479 // The Scala homepage and general information is at  | 
489 // The Scala homepage and general information is at  | 
480 //  | 
490 //  | 
513  | 
523  | 
514  | 
524  | 
515  | 
525  | 
516  | 
526  | 
517  | 
527  | 
518  | 
528 // declarative  | 
519  | 
529  | 
520  | 
530 users.filter(_.email.endsWith("@gmail.com"))  | 
521  | 
531  | 
522  | 
532 // imperative  | 
523  | 
533  | 
524  | 
534 val result = ListBuffer[User]()  | 
525  | 
535 for(user <- users) {  | 
526  | 
536 if(user.email.endsWith("@gmail.com")) {  | 
527  | 
537 result += user  | 
538 }  | 
|
539 }  | 
|
540 result.toList  | 
|
541  | 
|
542  | 
|
543  | 
|
544  | 
|
545  | 
|
546  | 
|
547  |