Sha256: b036680a2b11bbe1ae069c00adece4a57d9eaf7732501f5bcd457ee63f4698c7

Contents?: true

Size: 526 Bytes

Versions: 396

Compression:

Stored size: 526 Bytes

Contents

object Sublist extends Enumeration {
  def sublist[T](l1: List[T], l2: List[T]): Value = {
    if (equal(l1, l2)) Equal
    else if (isSublist(l1, l2)) Sublist
    else if (isSuperlist(l1, l2)) Superlist
    else Unequal
  }

  private def equal[T](l1: List[T], l2: List[T]) = l1.equals(l2)

  private def isSublist[T](l1: List[T], l2: List[T]) = l2.containsSlice(l1)

  private def isSuperlist[T](l1: List[T], l2: List[T]) = l1.containsSlice(l2)

  type SublistType = Value
  val Equal, Sublist, Superlist, Unequal = Value
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.0.0.5 tracks/scala/exercises/sublist/example.scala
trackler-2.0.0.4 tracks/scala/exercises/sublist/example.scala
trackler-2.0.0.3 tracks/scala/exercises/sublist/example.scala
trackler-2.0.0.2 tracks/scala/exercises/sublist/example.scala
trackler-2.0.0.1 tracks/scala/exercises/sublist/example.scala
trackler-2.0.0.0 tracks/scala/exercises/sublist/example.scala
trackler-1.0.4.1 tracks/scala/exercises/sublist/example.scala
trackler-1.0.4.0 tracks/scala/exercises/sublist/example.scala
trackler-1.0.3.0 tracks/scala/exercises/sublist/example.scala
trackler-1.0.2.1 tracks/scala/exercises/sublist/example.scala
trackler-1.0.2.0 tracks/scala/exercises/sublist/example.scala
trackler-1.0.1.2 tracks/scala/exercises/sublist/example.scala
trackler-1.0.1.1 tracks/scala/exercises/sublist/example.scala
trackler-1.0.1.0 tracks/scala/exercises/sublist/example.scala
trackler-1.0.0.1 tracks/scala/exercises/sublist/example.scala
trackler-1.0.0 tracks/scala/exercises/sublist/example.scala