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.2.1.180 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.179 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.178 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.177 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.176 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.175 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.174 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.173 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.172 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.171 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.170 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.169 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.167 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.166 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.165 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.164 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.163 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.162 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.161 tracks/scala/exercises/sublist/example.scala
trackler-2.2.1.160 tracks/scala/exercises/sublist/example.scala