Sha256: 4b322325db52a7d626ed4458139da74ec8fba616771d1d73004225e50f4b7faf

Contents?: true

Size: 933 Bytes

Versions: 59

Compression:

Stored size: 933 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 {" that %s %s".format(parts(i)._1, parts(i)._2)}).mkString + "\n"
  }

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

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

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/scala/exercises/house/example.scala
trackler-2.2.1.179 tracks/scala/exercises/house/example.scala
trackler-2.2.1.178 tracks/scala/exercises/house/example.scala
trackler-2.2.1.177 tracks/scala/exercises/house/example.scala
trackler-2.2.1.176 tracks/scala/exercises/house/example.scala
trackler-2.2.1.175 tracks/scala/exercises/house/example.scala
trackler-2.2.1.174 tracks/scala/exercises/house/example.scala
trackler-2.2.1.173 tracks/scala/exercises/house/example.scala
trackler-2.2.1.172 tracks/scala/exercises/house/example.scala
trackler-2.2.1.171 tracks/scala/exercises/house/example.scala
trackler-2.2.1.170 tracks/scala/exercises/house/example.scala
trackler-2.2.1.169 tracks/scala/exercises/house/example.scala
trackler-2.2.1.167 tracks/scala/exercises/house/example.scala
trackler-2.2.1.166 tracks/scala/exercises/house/example.scala
trackler-2.2.1.165 tracks/scala/exercises/house/example.scala
trackler-2.2.1.164 tracks/scala/exercises/house/example.scala
trackler-2.2.1.163 tracks/scala/exercises/house/example.scala
trackler-2.2.1.162 tracks/scala/exercises/house/example.scala
trackler-2.2.1.161 tracks/scala/exercises/house/example.scala
trackler-2.2.1.160 tracks/scala/exercises/house/example.scala