This page is no longer maintained — Please continue to the home page atwww.scala-lang.org
| Source | Description |
|---|---|
| addressbook.scala | Address book to XHTML code (see alsoXML Processing) |
| callccInterpreter.scala | Interpreter with continuations using monads |
| fors.scala | for comprehensions (see alsoSequence Comprehensions) |
| gadts.scala | Generalised algebraic data types |
| lazyEvaluation.scala | Lazy evaluation |
| message.scala | Actors (see also Actors for Scala) |
| patterns.scala | Pattern matching using case classes (see alsoCase Classes) |
| extractorPatterns.scala | Pattern matching using extractors - a flexible way of matching objects with patterns |
| pingpong.scala | Actors (see also Actors for Scala) |
| properties.scala | Properties |
| random.scala | Client/server application using Java sockets |
| simpleInterpreter.scala | Simple interpreter using monads |
| sort.scala | Recursive quicksort algorithm (imperative solution, see alsoNested Functions) |
| sort1.scala | Recursive quicksort algorithm (functional solution) |
| timeofday.scala | Properties (see example 1 in § 4.2 of theScala Language Specification) |
| vectors.scala | Vector operations using views (see alsoViews) |
| brainf_ck.scala | A small Brainf*ck interpreter |
To compile and run on Windows one of the above Scala programs, let's say sort.scala, we can simply proceed as follows:
> mkdir classes> scalac -d classes %SCALA_HOME%\doc\scala-devel\scala\examples\sort.scala> scala -cp classes examples.sort[6,2,8,5,1][1,2,5,6,8]
The name of the Scala executable is examples.sort where examples is the name of the package containing the sortobject. Running the test on a Unix system is very much similar, except for the use of slashes instead of backslashes, and a different specification of the Scala home directory.
Finally, the following ressources contain Scala examples as well:
examples with other source examples.
Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland