SlideShare a Scribd company logo
1 of 33
Download to read offline
1/33




                                                                    TÜRKİYE

                                 String Interpolation               presenter
                                                                    Volkan Yazıcı
                                            Streams                 https://twitter.com/yazicivo
                                Regular Expressions                 http://vyazici.blogspot.com
                                                                    http://github.com/vy
                                 Process Execution                  http://web.itu.edu.tr/~yazicivo/




https://groups.google.com/forum/?fromgroups=#!forum/scala-turkiye                                      2013-02-07
2/33




   Implicit Classes                                             simplify the creation of classes which
   provide extension methods to another type.




http://docs.scala-lang.org/sips/pending/implicit-classes.html
3/33



                        Implicit Classes
                                      Basics
scala> implicit class MyString(val str: String) {
     |   def quote: String = "'" + str + "'"
     | }
defined class MyString

scala> println("abc")
abc

scala> println("abc".quote)
'abc'
4/33



                        Implicit Classes
                                      Basics
scala> implicit class MyString(val str: String) {
     |   def quote: String = "'" + str + "'"
     | }
defined class MyString

scala> println("abc")
abc

scala> println("abc".quote)
'abc'

---------------------------------------------------------------------------------------

scala> implicit class MyInt(val n: Int) {
     |   def factorial: Int = {
     |     require(n >= 0)
     |     if (n < 2) 1
     |     else n * (n-1).factorial
     |   }
     | }
defined class MyInt

scala> 5.factorial
res3: Int = 120
5/33




   String Interpolation                                   allows users to embed
   variable references directly in processed string literals.




http://www.scala-lang.org/node/258
6/33



                 String Interpolation
                                      Basics
scala> val (str, num) = ("Walter White", 0.128F)
str: String = Walter White
num: Float = 0.128
7/33



                 String Interpolation
                                      Basics
scala> val (str, num) = ("Walter White", 0.128F)
str: String = Walter White
num: Float = 0.128

---------------------------------------------------------------------------------------

scala> println(s"str: $str, num: $num")
str: Walter White, num: 0.128
8/33



                 String Interpolation
                                      Basics
scala> val (str, num) = ("Walter White", 0.128F)
str: String = Walter White
num: Float = 0.128

---------------------------------------------------------------------------------------

scala> println(s"str: $str, num: $num")
str: Walter White, num: 0.128

---------------------------------------------------------------------------------------

scala> println(s"1 + 1 = ${1 + 1}”)
1 + 1 = 2

scala> println(s"2 * $num = ${2 * num}”)
2 * 0.128 = 0.256
9/33



                 String Interpolation
                                      Basics
scala> val (str, num) = ("Walter White", 0.128F)
str: String = Walter White
num: Float = 0.128

---------------------------------------------------------------------------------------

scala> println(s"str: $str, num: $num")
str: Walter White, num: 0.128

---------------------------------------------------------------------------------------

scala> println(s"1 + 1 = ${1 + 1}”)
1 + 1 = 2

scala> println(s"2 * $num = ${2 * num}”)
2 * 0.128 = 0.256

---------------------------------------------------------------------------------------

scala> println(f"num: $num%.2f")
Num: 0.13
10/33



                 String Interpolation
                                      Basics
scala> val (str, num) = ("Walter White", 0.128F)
str: String = Walter White
num: Float = 0.128

---------------------------------------------------------------------------------------

scala> println(s"str: $str, num: $num")
str: Walter White, num: 0.128

---------------------------------------------------------------------------------------

scala> println(s"1 + 1 = ${1 + 1}”)
1 + 1 = 2

scala> println(s"2 * $num = ${2 * num}”)
2 * 0.128 = 0.256

---------------------------------------------------------------------------------------

scala> println(f"num: $num%.2f")
Num: 0.13

---------------------------------------------------------------------------------------

scala> println(raw"anb u0040")
anb @
11/33



         String Interpolation
                     Internals



             Compiler transformation:

  id”string” ↔ StringContext(“string”).id()


  Existing StringContext methods: s, f, and raw.

We can extend StringContext using implicit classes.
12/33



                 String Interpolation
                                    Extending
scala> implicit class MyStringContext(val sc: StringContext) {
     |   def q(args: Any*): String = s"args: '$args', parts: '$sc.parts'"
     | }
defined class MyStringContext

scala> println(q"abc ${1+1} def")
args: 'WrappedArray(2)', parts: 'StringContext(WrappedArray(abc ,   def)).parts'
13/33




   A   Stream                       is like a list except that its elements are computed lazily.




http://www.scala-lang.org/api/current/scala/collection/immutable/Stream.html
14/33



                                Streams
                                        Basics
scala> Stream.cons(1, Stream.empty)
res0: Stream.Cons[Int] = Stream(1, ?)

scala> Stream.cons(1, Stream.empty): Stream[Int]
res1: Stream[Int] = Stream(1, ?)

scala> Stream.cons(1, Stream.empty).toList
res2: List[Int] = List(1)

scala> Stream.cons(1, Stream.cons(2, Stream.empty)).toList
res3: List[Int] = List(1, 2)
15/33



                                   Streams
                                        Basics
scala> Stream.cons(1, Stream.empty)
res0: Stream.Cons[Int] = Stream(1, ?)

scala> Stream.cons(1, Stream.empty): Stream[Int]
res1: Stream[Int] = Stream(1, ?)

scala> Stream.cons(1, Stream.empty).toList
res2: List[Int] = List(1)

scala> Stream.cons(1, Stream.cons(2, Stream.empty)).toList
res3: List[Int] = List(1, 2)

---------------------------------------------------------------------------------------

scala> def integers(n: Int): Stream[Int] = Stream.cons(n, integers(n+1))
integers: (from: Int)Stream[Int]

scala> integers(0)
res4: Stream[Int] = Stream(0, ?)

scala> integers(0).take(10)
res5: Stream[Int] = Stream(0, ?)

scala> integers(0).take(10).toList
res6: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
16/33



                                Streams
                                      Usage
scala> def evenNumbers: Stream[Int] = integers(0).filter(_ % 2 == 0)
evenNumbers: ()Stream[Int]

scala> evenNumbers.take(10).toList
res7: List[Int] = List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18)
17/33



                                Streams
                                      Usage
scala> def evenNumbers: Stream[Int] = integers(0).filter(_ % 2 == 0)
evenNumbers: ()Stream[Int]

scala> evenNumbers.take(10).toList
res7: List[Int] = List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18)

---------------------------------------------------------------------------------------

scala> Stream.continually(math.random).take(3).toList
res8: List[Double] = List(0.5932830094101399, 0.4377639789538802, 0.4522513999390704)
18/33



                                Streams
                                      Usage
scala> def evenNumbers: Stream[Int] = integers(0).filter(_ % 2 == 0)
evenNumbers: ()Stream[Int]

scala> evenNumbers.take(10).toList
res7: List[Int] = List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18)

---------------------------------------------------------------------------------------

scala> Stream.continually(math.random).take(3).toList
res8: List[Double] = List(0.5932830094101399, 0.4377639789538802, 0.4522513999390704)

---------------------------------------------------------------------------------------

scala> Stream.continually(List(1,2,3)).flatten.take(8).toList
res9: List[Int] = List(1, 2, 3, 1, 2, 3, 1, 2)
19/33



                                Streams
                                Recursion [1/2]
scala> def fibonacci: Stream[Int] =
           1 #:: 1 #:: fibonacci.zip(fibonacci.tail).map { case (x, y) => x + y }
fibonacci: Stream[Int]

scala> fibonacci.take(10).toList
res8: List[Int] = List(1, 1, 2, 3, 5, 8, 13, 21, 34, 55)
20/33



                                Streams
                                Recursion [2/2]
scala> def primes(implicit n: Int = 2): Stream[Int] = integers(n) match {
         case x #:: xs => x #:: primes(x+1).filter(_ % x != 0)
       }
primes: (implicit n: Int)Stream[Int]

scala> primes.take(10).toList
res17: List[Int] = List(2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
21/33



                                Streams
                                     Gotchas
scala> def naturalNumbers: Stream[Int] = integers(0)
naturalNumbers: ()Stream[Int]

scala> val naturalNumbers: Stream[Int] = integers(0)
naturalNumbers: Stream[Int] = Stream(0, ?)

scala> lazy val naturalNumbers: Stream[Int] = integers(0)
naturalNumbers: Stream[Int] = <lazy>
22/33




   Regular Expressions




http://www.scala-lang.org/api/current/index.html#scala.util.matching.Regex
23/33



                Regular Expressions
                                      Basics
scala> "0xDeadBeef" matches "0x[0-9a-fA-F]+"
res1: Boolean = true

scala> "abc 0x12 def" matches "0x[0-9a-fA-F]+"
res2: Boolean = false
24/33



                Regular Expressions
                                      Basics
scala> "0xDeadBeef" matches "0x[0-9a-fA-F]+"
res1: Boolean = true

scala> "abc 0x12 def" matches "0x[0-9a-fA-F]+"
res2: Boolean = false

---------------------------------------------------------------------------------------

scala> val dateRegex = "([0-9]{4})-([0-9]{2})-([0-9]{2})".r
hexregex: scala.util.matching.Regex = ([0-9]{4})-([0-9]{2})-([0-9]{2})

scala> dateRegex findFirstIn "2013-04-08" match {
     |   case Some(dateRegex(y, m, n)) => s"y: $y, m: $m, n: $n"
     |   case None => "invalid date"
     | }
res3: String = y: 2013, m: 04, n: 08

scala> dateRegex findAllIn "2013-04-08 2012-05-07" map {
     |   case dateRegex(y, m, n) => (y, m, n)
     | } toList
res4: List[(String, String, String)] = List((2013,04,08), (2012,05,07))
25/33




   Process Execution




http://www.scala-lang.org/api/current/index.html#scala.sys.process.package
26/33



                   Process Execution
                                    Basics
scala> import scala.sys.process._
import scala.sys.process._
27/33



                   Process Execution
                                      Basics
scala> import scala.sys.process._
import scala.sys.process._

---------------------------------------------------------------------------------------

scala> "/bin/false".!
res1: Int = 1

scala> "/bin/true".!
res2: Int = 0
28/33



                   Process Execution
                                           Basics
scala> import scala.sys.process._
import scala.sys.process._

---------------------------------------------------------------------------------------

scala> "/bin/false".!
res1: Int = 1

scala> "/bin/true".!
res2: Int = 0

---------------------------------------------------------------------------------------

scala> "uptime".!!
res3: String =
" 17:30:38 up 4 days,   3:41,   5 users,   load average: 1.18, 0.97, 0.79
"
29/33



                   Process Execution
                                      Basics
scala> import scala.sys.process._
import scala.sys.process._

---------------------------------------------------------------------------------------

scala> "/bin/false".!
res1: Int = 1

scala> "/bin/true".!
res2: Int = 0

---------------------------------------------------------------------------------------

scala> "uptime".!!
res3: String =
" 17:30:38 up 4 days, 3:41, 5 users, load average: 1.18, 0.97, 0.79
"
---------------------------------------------------------------------------------------

scala> Seq("ls").lines
res4: Stream[String] = Stream(Desktop, ?)

scala> Seq("ls").lines.toList
res5: List[String] = List(Desktop, Documents, Downloads, Music, …)

scala> Seq("ping", "-w", "1", "-c", "1", "google.com").lines
res6: Stream[String] = Stream(PING google.com (173.194.70.103) 56(84) bytes of data., ?)
30/33



                   Process Execution
                                       Magic
scala> def compile(file: String) =
     |   s"ls $file" #&& s"scalac $file" #|| "echo nothing found" lines
compile: (file: String)Stream[String]
31/33



                   Process Execution
                                       Magic
scala> def compile(file: String) =
     |   s"ls $file" #&& s"scalac $file" #|| "echo nothing found" lines
compile: (file: String)Stream[String]

---------------------------------------------------------------------------------------

scala> import java.io.File
import java.io.File

scala> import java.net.URL
import java.net.URL

scala> new URL("http://www.scala-lang.org/") #> new File("/tmp/scala-lang.html") !
res7: Int = 0
32/33



                   Process Execution
                                     Gotchas
scala> Seq("choke").lines
java.io.IOException: Cannot run program "choke": error=2, No such file or directory
33/33




Questions?

More Related Content

What's hot

Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With ScalaMeetu Maltiar
 
Scala parallel-collections
Scala parallel-collectionsScala parallel-collections
Scala parallel-collectionsKnoldus Inc.
 
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...Philip Schwarz
 
Programming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYProgramming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYvikram mahendra
 
Brief tour of psp-std
Brief tour of psp-stdBrief tour of psp-std
Brief tour of psp-stdPaul Phillips
 
Java 8 - project lambda
Java 8 - project lambdaJava 8 - project lambda
Java 8 - project lambdaIvar Østhus
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfacesJava8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfacesDirk Detering
 
Data Structures In Scala
Data Structures In ScalaData Structures In Scala
Data Structures In ScalaKnoldus Inc.
 
Sequence and Traverse - Part 3
Sequence and Traverse - Part 3Sequence and Traverse - Part 3
Sequence and Traverse - Part 3Philip Schwarz
 
Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!priort
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Java 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason SwartzJava 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason SwartzJason Swartz
 

What's hot (20)

Sparklyr
SparklyrSparklyr
Sparklyr
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With Scala
 
Scala parallel-collections
Scala parallel-collectionsScala parallel-collections
Scala parallel-collections
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
Quicksort - a whistle-stop tour of the algorithm in five languages and four p...
 
Programming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYProgramming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAY
 
Python
PythonPython
Python
 
Scala collections
Scala collectionsScala collections
Scala collections
 
ScalaBlitz
ScalaBlitzScalaBlitz
ScalaBlitz
 
Brief tour of psp-std
Brief tour of psp-stdBrief tour of psp-std
Brief tour of psp-std
 
Java 8 - project lambda
Java 8 - project lambdaJava 8 - project lambda
Java 8 - project lambda
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfacesJava8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
 
Stack, queue and hashing
Stack, queue and hashingStack, queue and hashing
Stack, queue and hashing
 
Python Cheat Sheet
Python Cheat SheetPython Cheat Sheet
Python Cheat Sheet
 
Data Structures In Scala
Data Structures In ScalaData Structures In Scala
Data Structures In Scala
 
Sequence and Traverse - Part 3
Sequence and Traverse - Part 3Sequence and Traverse - Part 3
Sequence and Traverse - Part 3
 
Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Java 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason SwartzJava 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason Swartz
 

Viewers also liked

Viewers also liked (10)

How to increase the interest of Engineering among students
How to increase the interest of Engineering among studentsHow to increase the interest of Engineering among students
How to increase the interest of Engineering among students
 
путешествие с нефтью
путешествие с нефтьюпутешествие с нефтью
путешествие с нефтью
 
All About Best Western Wana Riverside Hotel
All About Best Western Wana Riverside HotelAll About Best Western Wana Riverside Hotel
All About Best Western Wana Riverside Hotel
 
علم الحديث رواية ودراية
علم الحديث رواية ودرايةعلم الحديث رواية ودراية
علم الحديث رواية ودراية
 
CONGRESO PROVINCIAL CAM SUR
CONGRESO PROVINCIAL CAM SURCONGRESO PROVINCIAL CAM SUR
CONGRESO PROVINCIAL CAM SUR
 
Rico de coro
Rico de coroRico de coro
Rico de coro
 
Problem solving exercises
Problem solving exercisesProblem solving exercises
Problem solving exercises
 
Mind, Brain and Relationships
Mind, Brain and RelationshipsMind, Brain and Relationships
Mind, Brain and Relationships
 
90 EJERCICIOS PARA PRACTICAR ORTOGRAFÍA Y GRAMÁTICA
90 EJERCICIOS PARA PRACTICAR ORTOGRAFÍA Y GRAMÁTICA 90 EJERCICIOS PARA PRACTICAR ORTOGRAFÍA Y GRAMÁTICA
90 EJERCICIOS PARA PRACTICAR ORTOGRAFÍA Y GRAMÁTICA
 
Modulo V Confección Textil 2016
Modulo  V Confección Textil 2016Modulo  V Confección Textil 2016
Modulo V Confección Textil 2016
 

Similar to Scala Turkiye 2013-02-07 Sunumu

Introduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with sparkIntroduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with sparkAngelo Leto
 
ReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherColin Eberhardt
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data ManagementAlbert Bifet
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1Giovanni Della Lunga
 
JPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream APIJPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream APItvaleev
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7decoupled
 
Functional programming with_scala
Functional programming with_scalaFunctional programming with_scala
Functional programming with_scalaRaymond Tay
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript ObjectsReem Alattas
 
Legacy lambda code
Legacy lambda codeLegacy lambda code
Legacy lambda codePeter Lawrey
 
Scaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaScaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaOstap Andrusiv
 

Similar to Scala Turkiye 2013-02-07 Sunumu (20)

Introduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with sparkIntroduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with spark
 
ReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better TogetherReactiveCocoa and Swift, Better Together
ReactiveCocoa and Swift, Better Together
 
Spark workshop
Spark workshopSpark workshop
Spark workshop
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
JPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream APIJPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream API
 
Mysql1
Mysql1Mysql1
Mysql1
 
Scala Collections
Scala CollectionsScala Collections
Scala Collections
 
Spark_Documentation_Template1
Spark_Documentation_Template1Spark_Documentation_Template1
Spark_Documentation_Template1
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
Functional programming with_scala
Functional programming with_scalaFunctional programming with_scala
Functional programming with_scala
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
tidyr.pdf
tidyr.pdftidyr.pdf
tidyr.pdf
 
Legacy lambda code
Legacy lambda codeLegacy lambda code
Legacy lambda code
 
Scaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaScaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with Scala
 
Scala by Luc Duponcheel
Scala by Luc DuponcheelScala by Luc Duponcheel
Scala by Luc Duponcheel
 

Recently uploaded

💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service
💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service
💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt ServiceApsara Of India
 
💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞
💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞
💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞Apsara Of India
 
AliExpress Clothing Brand Media Planning
AliExpress Clothing Brand Media PlanningAliExpress Clothing Brand Media Planning
AliExpress Clothing Brand Media Planningjen_giacalone
 
Panipat Call Girls in Five Star Services Call 08860008073
Panipat Call Girls in Five Star Services Call 08860008073 Panipat Call Girls in Five Star Services Call 08860008073
Panipat Call Girls in Five Star Services Call 08860008073 Apsara Of India
 
Call Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy Girls
Call Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy GirlsCall Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy Girls
Call Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy GirlsPooja Nehwal
 
Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️
Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️
Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️soniya singh
 
Moscow City People project Roman Kurganov
Moscow City People project Roman KurganovMoscow City People project Roman Kurganov
Moscow City People project Roman KurganovRomanKurganov
 
Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...
Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...
Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...Pooja Nehwal
 
Hi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura Bhopalpura
Hi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura BhopalpuraHi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura Bhopalpura
Hi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura BhopalpuraApsara Of India
 
Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.soniya singh
 
Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -
Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -
Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -Pooja Nehwal
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip CallMs Riya
 
Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=
Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=
Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=kojalkojal131
 
Call Girls In Lajpat Nagar__ 8448079011 __Escort Service In Delhi
Call Girls In Lajpat Nagar__ 8448079011 __Escort Service In DelhiCall Girls In Lajpat Nagar__ 8448079011 __Escort Service In Delhi
Call Girls In Lajpat Nagar__ 8448079011 __Escort Service In DelhiRaviSingh594208
 
Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...
Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...
Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...hf8803863
 
💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service
💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service
💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort ServiceApsara Of India
 
Call Girls In Goa 7028418221 Call Girls In Colva Beach Escorts Service
Call Girls In Goa 7028418221 Call Girls In Colva Beach Escorts ServiceCall Girls In Goa 7028418221 Call Girls In Colva Beach Escorts Service
Call Girls In Goa 7028418221 Call Girls In Colva Beach Escorts ServiceApsara Of India
 
Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012
Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012
Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012Mona Rathore
 
Top 10 Makeup Brands in India for women
Top 10  Makeup Brands in India for womenTop 10  Makeup Brands in India for women
Top 10 Makeup Brands in India for womenAkshitaBhatt19
 

Recently uploaded (20)

💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service
💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service
💞Call Girls In Sonipat 08168329307 Sonipat Kundli GTK Bypass EsCoRt Service
 
💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞
💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞
💞SEXY💞 UDAIPUR ESCORTS 09602870969 CaLL GiRLS in UdAiPuR EsCoRt SeRvIcE💞
 
AliExpress Clothing Brand Media Planning
AliExpress Clothing Brand Media PlanningAliExpress Clothing Brand Media Planning
AliExpress Clothing Brand Media Planning
 
Panipat Call Girls in Five Star Services Call 08860008073
Panipat Call Girls in Five Star Services Call 08860008073 Panipat Call Girls in Five Star Services Call 08860008073
Panipat Call Girls in Five Star Services Call 08860008073
 
Call Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy Girls
Call Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy GirlsCall Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy Girls
Call Girls In Vashi Call Girls Pooja 📞 9892124323 ✅Book Hot And Sexy Girls
 
Hauz Khas Call Girls Delhi ✌️Independent Escort Service 💕 Hot Model's 9999965857
Hauz Khas Call Girls Delhi ✌️Independent Escort Service 💕 Hot Model's 9999965857Hauz Khas Call Girls Delhi ✌️Independent Escort Service 💕 Hot Model's 9999965857
Hauz Khas Call Girls Delhi ✌️Independent Escort Service 💕 Hot Model's 9999965857
 
Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️
Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️
Call Girls in civil lines Delhi 8264348440 ✅ call girls ❤️
 
Moscow City People project Roman Kurganov
Moscow City People project Roman KurganovMoscow City People project Roman Kurganov
Moscow City People project Roman Kurganov
 
Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...
Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...
Mumbai Call Girls Andheri East WhatsApp 9167673311 💞 Full Night Enjoy Pooja M...
 
Hi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura Bhopalpura
Hi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura BhopalpuraHi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura Bhopalpura
Hi Profile Escorts In Udaipur 09602870969 Call Girls in Sobaghpura Bhopalpura
 
Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Govindpuri Escort Service Delhi N.C.R.
 
Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -
Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -
Mumbai Call Girls Malad West WhatsApp 9892124323 Full Night Enjoy -
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199012 ☎️ Hard And Sexy Vip Call
 
Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=
Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=
Dubai Call Girls Phone O525547819 Take+ Call Girls Dubai=
 
Call Girls In Lajpat Nagar__ 8448079011 __Escort Service In Delhi
Call Girls In Lajpat Nagar__ 8448079011 __Escort Service In DelhiCall Girls In Lajpat Nagar__ 8448079011 __Escort Service In Delhi
Call Girls In Lajpat Nagar__ 8448079011 __Escort Service In Delhi
 
Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...
Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...
Jumeirah Call Girls Dubai Concupis O528786472 Dubai Call Girls In Bur Dubai N...
 
💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service
💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service
💕COD Call Girls In Kurukshetra 08168329307 Pehowa Escort Service
 
Call Girls In Goa 7028418221 Call Girls In Colva Beach Escorts Service
Call Girls In Goa 7028418221 Call Girls In Colva Beach Escorts ServiceCall Girls In Goa 7028418221 Call Girls In Colva Beach Escorts Service
Call Girls In Goa 7028418221 Call Girls In Colva Beach Escorts Service
 
Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012
Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012
Russian BINDASH Call Girls In Mahipalpur Delhi ☎️9711199012
 
Top 10 Makeup Brands in India for women
Top 10  Makeup Brands in India for womenTop 10  Makeup Brands in India for women
Top 10 Makeup Brands in India for women
 

Scala Turkiye 2013-02-07 Sunumu

  • 1. 1/33 TÜRKİYE String Interpolation presenter Volkan Yazıcı Streams https://twitter.com/yazicivo Regular Expressions http://vyazici.blogspot.com http://github.com/vy Process Execution http://web.itu.edu.tr/~yazicivo/ https://groups.google.com/forum/?fromgroups=#!forum/scala-turkiye 2013-02-07
  • 2. 2/33 Implicit Classes simplify the creation of classes which provide extension methods to another type. http://docs.scala-lang.org/sips/pending/implicit-classes.html
  • 3. 3/33 Implicit Classes Basics scala> implicit class MyString(val str: String) { | def quote: String = "'" + str + "'" | } defined class MyString scala> println("abc") abc scala> println("abc".quote) 'abc'
  • 4. 4/33 Implicit Classes Basics scala> implicit class MyString(val str: String) { | def quote: String = "'" + str + "'" | } defined class MyString scala> println("abc") abc scala> println("abc".quote) 'abc' --------------------------------------------------------------------------------------- scala> implicit class MyInt(val n: Int) { | def factorial: Int = { | require(n >= 0) | if (n < 2) 1 | else n * (n-1).factorial | } | } defined class MyInt scala> 5.factorial res3: Int = 120
  • 5. 5/33 String Interpolation allows users to embed variable references directly in processed string literals. http://www.scala-lang.org/node/258
  • 6. 6/33 String Interpolation Basics scala> val (str, num) = ("Walter White", 0.128F) str: String = Walter White num: Float = 0.128
  • 7. 7/33 String Interpolation Basics scala> val (str, num) = ("Walter White", 0.128F) str: String = Walter White num: Float = 0.128 --------------------------------------------------------------------------------------- scala> println(s"str: $str, num: $num") str: Walter White, num: 0.128
  • 8. 8/33 String Interpolation Basics scala> val (str, num) = ("Walter White", 0.128F) str: String = Walter White num: Float = 0.128 --------------------------------------------------------------------------------------- scala> println(s"str: $str, num: $num") str: Walter White, num: 0.128 --------------------------------------------------------------------------------------- scala> println(s"1 + 1 = ${1 + 1}”) 1 + 1 = 2 scala> println(s"2 * $num = ${2 * num}”) 2 * 0.128 = 0.256
  • 9. 9/33 String Interpolation Basics scala> val (str, num) = ("Walter White", 0.128F) str: String = Walter White num: Float = 0.128 --------------------------------------------------------------------------------------- scala> println(s"str: $str, num: $num") str: Walter White, num: 0.128 --------------------------------------------------------------------------------------- scala> println(s"1 + 1 = ${1 + 1}”) 1 + 1 = 2 scala> println(s"2 * $num = ${2 * num}”) 2 * 0.128 = 0.256 --------------------------------------------------------------------------------------- scala> println(f"num: $num%.2f") Num: 0.13
  • 10. 10/33 String Interpolation Basics scala> val (str, num) = ("Walter White", 0.128F) str: String = Walter White num: Float = 0.128 --------------------------------------------------------------------------------------- scala> println(s"str: $str, num: $num") str: Walter White, num: 0.128 --------------------------------------------------------------------------------------- scala> println(s"1 + 1 = ${1 + 1}”) 1 + 1 = 2 scala> println(s"2 * $num = ${2 * num}”) 2 * 0.128 = 0.256 --------------------------------------------------------------------------------------- scala> println(f"num: $num%.2f") Num: 0.13 --------------------------------------------------------------------------------------- scala> println(raw"anb u0040") anb @
  • 11. 11/33 String Interpolation Internals Compiler transformation: id”string” ↔ StringContext(“string”).id() Existing StringContext methods: s, f, and raw. We can extend StringContext using implicit classes.
  • 12. 12/33 String Interpolation Extending scala> implicit class MyStringContext(val sc: StringContext) { | def q(args: Any*): String = s"args: '$args', parts: '$sc.parts'" | } defined class MyStringContext scala> println(q"abc ${1+1} def") args: 'WrappedArray(2)', parts: 'StringContext(WrappedArray(abc , def)).parts'
  • 13. 13/33 A Stream is like a list except that its elements are computed lazily. http://www.scala-lang.org/api/current/scala/collection/immutable/Stream.html
  • 14. 14/33 Streams Basics scala> Stream.cons(1, Stream.empty) res0: Stream.Cons[Int] = Stream(1, ?) scala> Stream.cons(1, Stream.empty): Stream[Int] res1: Stream[Int] = Stream(1, ?) scala> Stream.cons(1, Stream.empty).toList res2: List[Int] = List(1) scala> Stream.cons(1, Stream.cons(2, Stream.empty)).toList res3: List[Int] = List(1, 2)
  • 15. 15/33 Streams Basics scala> Stream.cons(1, Stream.empty) res0: Stream.Cons[Int] = Stream(1, ?) scala> Stream.cons(1, Stream.empty): Stream[Int] res1: Stream[Int] = Stream(1, ?) scala> Stream.cons(1, Stream.empty).toList res2: List[Int] = List(1) scala> Stream.cons(1, Stream.cons(2, Stream.empty)).toList res3: List[Int] = List(1, 2) --------------------------------------------------------------------------------------- scala> def integers(n: Int): Stream[Int] = Stream.cons(n, integers(n+1)) integers: (from: Int)Stream[Int] scala> integers(0) res4: Stream[Int] = Stream(0, ?) scala> integers(0).take(10) res5: Stream[Int] = Stream(0, ?) scala> integers(0).take(10).toList res6: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  • 16. 16/33 Streams Usage scala> def evenNumbers: Stream[Int] = integers(0).filter(_ % 2 == 0) evenNumbers: ()Stream[Int] scala> evenNumbers.take(10).toList res7: List[Int] = List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18)
  • 17. 17/33 Streams Usage scala> def evenNumbers: Stream[Int] = integers(0).filter(_ % 2 == 0) evenNumbers: ()Stream[Int] scala> evenNumbers.take(10).toList res7: List[Int] = List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18) --------------------------------------------------------------------------------------- scala> Stream.continually(math.random).take(3).toList res8: List[Double] = List(0.5932830094101399, 0.4377639789538802, 0.4522513999390704)
  • 18. 18/33 Streams Usage scala> def evenNumbers: Stream[Int] = integers(0).filter(_ % 2 == 0) evenNumbers: ()Stream[Int] scala> evenNumbers.take(10).toList res7: List[Int] = List(0, 2, 4, 6, 8, 10, 12, 14, 16, 18) --------------------------------------------------------------------------------------- scala> Stream.continually(math.random).take(3).toList res8: List[Double] = List(0.5932830094101399, 0.4377639789538802, 0.4522513999390704) --------------------------------------------------------------------------------------- scala> Stream.continually(List(1,2,3)).flatten.take(8).toList res9: List[Int] = List(1, 2, 3, 1, 2, 3, 1, 2)
  • 19. 19/33 Streams Recursion [1/2] scala> def fibonacci: Stream[Int] = 1 #:: 1 #:: fibonacci.zip(fibonacci.tail).map { case (x, y) => x + y } fibonacci: Stream[Int] scala> fibonacci.take(10).toList res8: List[Int] = List(1, 1, 2, 3, 5, 8, 13, 21, 34, 55)
  • 20. 20/33 Streams Recursion [2/2] scala> def primes(implicit n: Int = 2): Stream[Int] = integers(n) match { case x #:: xs => x #:: primes(x+1).filter(_ % x != 0) } primes: (implicit n: Int)Stream[Int] scala> primes.take(10).toList res17: List[Int] = List(2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
  • 21. 21/33 Streams Gotchas scala> def naturalNumbers: Stream[Int] = integers(0) naturalNumbers: ()Stream[Int] scala> val naturalNumbers: Stream[Int] = integers(0) naturalNumbers: Stream[Int] = Stream(0, ?) scala> lazy val naturalNumbers: Stream[Int] = integers(0) naturalNumbers: Stream[Int] = <lazy>
  • 22. 22/33 Regular Expressions http://www.scala-lang.org/api/current/index.html#scala.util.matching.Regex
  • 23. 23/33 Regular Expressions Basics scala> "0xDeadBeef" matches "0x[0-9a-fA-F]+" res1: Boolean = true scala> "abc 0x12 def" matches "0x[0-9a-fA-F]+" res2: Boolean = false
  • 24. 24/33 Regular Expressions Basics scala> "0xDeadBeef" matches "0x[0-9a-fA-F]+" res1: Boolean = true scala> "abc 0x12 def" matches "0x[0-9a-fA-F]+" res2: Boolean = false --------------------------------------------------------------------------------------- scala> val dateRegex = "([0-9]{4})-([0-9]{2})-([0-9]{2})".r hexregex: scala.util.matching.Regex = ([0-9]{4})-([0-9]{2})-([0-9]{2}) scala> dateRegex findFirstIn "2013-04-08" match { | case Some(dateRegex(y, m, n)) => s"y: $y, m: $m, n: $n" | case None => "invalid date" | } res3: String = y: 2013, m: 04, n: 08 scala> dateRegex findAllIn "2013-04-08 2012-05-07" map { | case dateRegex(y, m, n) => (y, m, n) | } toList res4: List[(String, String, String)] = List((2013,04,08), (2012,05,07))
  • 25. 25/33 Process Execution http://www.scala-lang.org/api/current/index.html#scala.sys.process.package
  • 26. 26/33 Process Execution Basics scala> import scala.sys.process._ import scala.sys.process._
  • 27. 27/33 Process Execution Basics scala> import scala.sys.process._ import scala.sys.process._ --------------------------------------------------------------------------------------- scala> "/bin/false".! res1: Int = 1 scala> "/bin/true".! res2: Int = 0
  • 28. 28/33 Process Execution Basics scala> import scala.sys.process._ import scala.sys.process._ --------------------------------------------------------------------------------------- scala> "/bin/false".! res1: Int = 1 scala> "/bin/true".! res2: Int = 0 --------------------------------------------------------------------------------------- scala> "uptime".!! res3: String = " 17:30:38 up 4 days, 3:41, 5 users, load average: 1.18, 0.97, 0.79 "
  • 29. 29/33 Process Execution Basics scala> import scala.sys.process._ import scala.sys.process._ --------------------------------------------------------------------------------------- scala> "/bin/false".! res1: Int = 1 scala> "/bin/true".! res2: Int = 0 --------------------------------------------------------------------------------------- scala> "uptime".!! res3: String = " 17:30:38 up 4 days, 3:41, 5 users, load average: 1.18, 0.97, 0.79 " --------------------------------------------------------------------------------------- scala> Seq("ls").lines res4: Stream[String] = Stream(Desktop, ?) scala> Seq("ls").lines.toList res5: List[String] = List(Desktop, Documents, Downloads, Music, …) scala> Seq("ping", "-w", "1", "-c", "1", "google.com").lines res6: Stream[String] = Stream(PING google.com (173.194.70.103) 56(84) bytes of data., ?)
  • 30. 30/33 Process Execution Magic scala> def compile(file: String) = | s"ls $file" #&& s"scalac $file" #|| "echo nothing found" lines compile: (file: String)Stream[String]
  • 31. 31/33 Process Execution Magic scala> def compile(file: String) = | s"ls $file" #&& s"scalac $file" #|| "echo nothing found" lines compile: (file: String)Stream[String] --------------------------------------------------------------------------------------- scala> import java.io.File import java.io.File scala> import java.net.URL import java.net.URL scala> new URL("http://www.scala-lang.org/") #> new File("/tmp/scala-lang.html") ! res7: Int = 0
  • 32. 32/33 Process Execution Gotchas scala> Seq("choke").lines java.io.IOException: Cannot run program "choke": error=2, No such file or directory