Sha256: f952c4d1d27818daf076621fc2c1e78e44aebb5dee3dbc0467f5ac4eb59f5842

Contents?: true

Size: 920 Bytes

Versions: 12

Compression:

Stored size: 920 Bytes

Contents

object House {
  private val parts = Vector(("lay in", "the house that Jack built."),
    ("ate", "the malt"),
    ("killed", "the rat"),
    ("worried", "the cat"),
    ("tossed", "the dog"),
    ("milked", "the cow with the crumpled horn"),
    ("kissed", "the maiden all forlorn"),
    ("married", "the man all tattered and torn"),
    ("woke", "the priest all shaven and shorn"),
    ("kept", "the rooster that crowed in the morn"),
    ("belonged to", "the farmer sowing his corn"),
    ("", "the horse and the hound and the horn"))

  private def reciteInternal(n: Int) = {
    "This is " + parts(n)._2 +
      (for {
        i <- List.range(0, n).reverse
      } yield {"\nthat %s %s".format(parts(i)._1, parts(i)._2)}).mkString +
      "\n\n"
  }

  def recite(n: Int): String = reciteInternal(n - 1)

  def recite(n: Int, m: Int): String = (for {i <- List.range(n - 1, m)} yield {reciteInternal(i)}).mkString
}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
trackler-2.2.1.120 tracks/scala/exercises/house/example.scala
trackler-2.2.1.119 tracks/scala/exercises/house/example.scala
trackler-2.2.1.118 tracks/scala/exercises/house/example.scala
trackler-2.2.1.117 tracks/scala/exercises/house/example.scala
trackler-2.2.1.116 tracks/scala/exercises/house/example.scala
trackler-2.2.1.115 tracks/scala/exercises/house/example.scala
trackler-2.2.1.114 tracks/scala/exercises/house/example.scala
trackler-2.2.1.113 tracks/scala/exercises/house/example.scala
trackler-2.2.1.111 tracks/scala/exercises/house/example.scala
trackler-2.2.1.110 tracks/scala/exercises/house/example.scala
trackler-2.2.1.109 tracks/scala/exercises/house/example.scala
trackler-2.2.1.108 tracks/scala/exercises/house/example.scala