Meme in Scala
Sebastian over at Digifesto recently alerted me to a budding meme being pushed by Eric Florenzano. The original proposal (from here) goes like this:
Rules:
- Implement a program that takes in a user’s name and their age, and prints hello to them once for every year that they have been alive.
- Post these rules, the source code for your solution, and the following list (with you included) on your blog.
- Bonus points if you implement it in a language not yet seen on the following list!
The List:
- [Python]
http://www.eflorenzano.com/blog/post/trying-start-programming-meme
- [Bash]
http://aartemenko.com/texts/bash-meme/
- [C]
http://dakrauth.com/media/site/text/hello.c
- [Java]
http://adoleo.com/blog/2008/nov/25/programming-meme/
- [Python 3]
http://mikewatkins.ca/2008/11/25/hello-meme/
- [Ruby]
http://stroky.l.googlepages.com/gem
- [Ruby]
http://im.camronflanders.com/archive/meme/
- [Lisp]
http://justinlilly.com/blog/2008/nov/25/back-on-the-horse/
- [Lua]
http://aartemenko.com/texts/lua-hello-meme/
- [Functional Python]
http://aartemenko.com/texts/python-functional-hello-meme/
- [Erlang]
http://surfacedepth.blogspot.com/2008/11/erics-programming-meme-in-erlang.html
- [Haskell]
http://jasonwalsh.us/meme.html
- [PHP]
http://fitzgeraldsteele.wordpress.com/2008/11/25/memeing-in-php-2/
- [Javascript]
http://www.taylanpince.com/blog/posts/responding-to-a-programming-meme/
- [Single-File Django]
http://www.pocketuniverse.ca/archive/2008/november/27/florenzano-factor/
For my entry, I put together a script in Scala.
import scala.Console._
var name = readLine("What is your name? ")
var age = readLine("How many years old are you? ").toInt
(1 to age).foreach { age => println("%2d) Hello, %s".format(age, name)) }
To run, copy the code into a text file named hello.scala and then run: scala hello.scala You can get the scala interpreter from the Scala website, or your distribution’s package manager.
on November 28, 2009 on 8:49 am
[...] the sort of porting exercise Bill Kerr gave his students or the try-a-different-language meme that Dwins and Seb have taken up (in Scala and Prolog, respectively). I could also run through interesting [...]