introprog

This is the documentation of the introprog Scala Library with beginner-friendly utilities used in computer science teaching at Lund University. The open source code is hosted at https://github.com/lunduniversity/introprog-scalalib.

Package contents

How to use introprog-scalalib

Using scala-cli

You need Scala Command Line Interface

Add these magic comment lines starting with //> in the beginning of your Scala 3 file:

//> using scala 3
//> using dep "se.lth.cs::introprog:1.4.0"

You can choose the latest stable Scala version, or any version from at least Scala 3.3.3.

You run your code with scala-cli run . (note the ending dot, meaning "this dir")

If your program looks like this:

//> using scala 3
//> using dep "se.lth.cs::introprog:1.4.0"

@main def MyMain =
  val w = introprog.PixelWindow()
  w.drawText("Hello introprog.PixelWindow!", x = 100, y = 100)

You should see green text in a new window after executing:

scala-cli run .

See: api documentation for PixelWindow

Using sbt

If you have sbt installed at least version 1.10.0 then you can put this text in a file called build.sbt

scalaVersion := "3.4.2"  // or any Scala version from at least 3.3.3
libraryDependencies += "se.lth.cs" %% "introprog" % "1.4.0"

When you run sbt in a terminal, with the above in your build.sbt, the introprog lib is automatically downloaded and made available on your classpath. Then you can do things like:

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

Manual download

You can also manually download the latest jar file from here:

Lund University: http://www.cs.lth.se/pgk/lib

GitHub: https://github.com/lunduniversity/introprog-scalalib/releases

ScalaDex: https://index.scala-lang.org/lunduniversity/introprog-scalalib/introprog

Maven Central: https://repo1.maven.org/maven2/se/lth/cs/introprog_3/

Attributes

Members list

Packages

package introprog