Sha256: 6895d30d45bb3995c41626fd9b1ec362b252c9598a901ea63965f804999aee1a

Contents?: true

Size: 916 Bytes

Versions: 95

Compression:

Stored size: 916 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 verseInternal(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 verse(n: Int): String = verseInternal(n - 1)

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

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
trackler-2.2.1.107 tracks/scala/exercises/house/example.scala
trackler-2.2.1.106 tracks/scala/exercises/house/example.scala
trackler-2.2.1.105 tracks/scala/exercises/house/example.scala
trackler-2.2.1.104 tracks/scala/exercises/house/example.scala
trackler-2.2.1.103 tracks/scala/exercises/house/example.scala
trackler-2.2.1.102 tracks/scala/exercises/house/example.scala
trackler-2.2.1.101 tracks/scala/exercises/house/example.scala
trackler-2.2.1.100 tracks/scala/exercises/house/example.scala
trackler-2.2.1.99 tracks/scala/exercises/house/example.scala
trackler-2.2.1.98 tracks/scala/exercises/house/example.scala
trackler-2.2.1.97 tracks/scala/exercises/house/example.scala
trackler-2.2.1.96 tracks/scala/exercises/house/example.scala
trackler-2.2.1.95 tracks/scala/exercises/house/example.scala
trackler-2.2.1.94 tracks/scala/exercises/house/example.scala
trackler-2.2.1.93 tracks/scala/exercises/house/example.scala
trackler-2.2.1.92 tracks/scala/exercises/house/example.scala
trackler-2.2.1.91 tracks/scala/exercises/house/example.scala
trackler-2.2.1.90 tracks/scala/exercises/house/example.scala
trackler-2.2.1.89 tracks/scala/exercises/house/example.scala
trackler-2.2.1.88 tracks/scala/exercises/house/example.scala