SList

sealed abstract class SList

A class of singly-linked immutable lists of integers.

SList differs from List three main ways:

  1. It only supports integers as elements, and therefore does not take a type parameter.
  2. It supports only a handful of methods (but those that it does support exactly mirror the equivalent List methods).
  3. It is NOT designed to support pattern matching.
Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def head: Int

Returns the first element of the list.

Returns the first element of the list.

Throws NoSuchElementException if the list is empty.

def tail: SList

Returns the rest of the list without the first element.

Returns the rest of the list without the first element.

Throws UnsupportedOperationException if the list is empty.

Concrete methods

def ::(elem: Int): SList

Adds an element to the front of the list.

Adds an element to the front of the list.

def isEmpty: Boolean

Tests whether the list is empty.

Tests whether the list is empty.

def nonEmpty: Boolean

Tests whether the list has at least one element.

Tests whether the list has at least one element.

override def toString(): String
Definition Classes
Any