Skip to content
Scala library with simple-to-use utilites for students of introductory programming. http://cs.lth.se/pgk/api
Scala Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE
PUBLISH.md
README.md
build.sbt
publish-doc.sh
publish-jar.sh
publish-workspace.sh

README.md

introprog-scalalib

Build Status

This is a library with Scala utilities for Computer Science teaching. The library is maintained by Björn Regnell at Lund University, Sweden. Contributions are welcome!

This repo is used in this course (in Swedish): http://cs.lth.se/pgk with course material published as free open source here: https://github.com/lunduniversity/introprog

How to use introprog-scalalib

Using sbt

If you have the Scala Build Tool then you can put this text in a file called build.sbt

scalaVersion := "2.12.10"
libraryDependencies += "se.lth.cs" %% "introprog" % "1.1.4"

When you run sbt in terminal the introprog package is automatically downloaded and made available on your classpath. You can do things like:

> sbt
sbt> console
scala> val w = new introprog.PixelWindow()
scala> w.fill(100,100,100,100,java.awt.Color.red)

Manual download

Download the latest jar-file from here: https://github.com/lunduniversity/introprog-scalalib/releases

Or from Maven central here: https://search.maven.org/search?q=a:introprog_2.12

Or get any version from here: https://repo1.maven.org/maven2/se/lth/cs/introprog_2.12/

Put the jar-file on your classpath when you run the Scala REPL, for example:

> scala -cp introprog_2.12-1.1.4.jar
scala> val w = new introprog.PixelWindow()
scala> w.fill(100,100,100,100,java.awt.Color.red)
scala>

Put the jar-file on your classpath when you run your Scala app, for example:

> scala -cp "introprog_2.12-1.1.4.jar:." Main

If on Windows cmd/powershell use ; instead of : before the period.

How to build introprog-scalalib

With sbt and git on your path type in terminal:

> git clone git@github.com:lunduniversity/introprog-scalalib.git
> cd introprog-scalalib
> sbt package

Intentions and philosophy behind introprog-scalalib

This repo includes utilities to empower learners to advance from basic to intermediate levels of computer science by providing easy-to-use constructs for creating simple desktop apps in terminal and using simple 2D graphics. The utilities are implemented and exposed through an api that follows these guidelines:

  • Use as simple constructs as possible.
  • Follow Scala idioms with a pragmatic mix of imperative, functional and object-oriented programming.
  • Don't use advanced functional programming concepts and magical implicit.
  • Prefer a clean api with single-responsibility functions in simple modules.
  • Prefer immutability over mutable state, Vector for sequences and case classes for data.
  • Hide/avoid threading and complicated concurrency.
  • Inspiration:

Areas currently in scope of this library:

  • Simple pixel-based 2D graphics for single-threaded game programming with explicit game loop.
  • Simple blocking IO that hides the underlying complication of releasing resources etc.
  • Simple modal GUI dialogs that blocks while waiting for user response.
You can’t perform that action at this time.