Created
June 9, 2012 08:54
-
-
Save daiksy/2900182 to your computer and use it in GitHub Desktop.
message clear
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.gist.daiksy | |
/** | |
* エドウィン・モーガンという現代詩人の作品に | |
* "message clear"というものがあります. | |
* http://www.elgin.free-online.co.uk/misc/message.htm | |
* | |
* これは,1968年の彼の詩集に含まれている作品で, | |
* コンピュータが文章を書いたらどうなるか, | |
* という当時流行した議論をテーマに作られた作品です. | |
* | |
* これをScalaで表現してみました. | |
* hesitationList は和訳すると「ためらいリスト」 | |
* コンピュータのためらいを,このList[List[Int]]によって | |
* 表現しています. | |
* | |
* もう少しエレガントに書ける方法ないかなー,とも思います. | |
*/ | |
case class MessageClear() { | |
private val message = "i am the resurrection and the life" | |
private val hesitationList = List( | |
List(2,3,31), | |
List(31,32), | |
List(0,2,3,27,28), | |
List(6,7,9,19), | |
List(6,12,13,17), | |
List(5,6,7,9,10,22,23,24), | |
List(6,7,15,16,22,23,24), | |
List(6,7,9,10), | |
List(2,20,24), | |
List(5,6,7,9,28), | |
List(0,2,3,9,31,32,33), | |
List(18,20), | |
List(11,18,19,20,22,23,24), | |
List(0,24,31,33), | |
List(2,3,7,9,10,11,15,16,17), | |
List(2,3,7,9,10,11,15,16,17,18,19,20), | |
List(19,32), | |
List(5,6,7,30,31,32,33), | |
List(19,32), | |
List(3,7,20), | |
List(11,12,13,15), | |
List(5,6,7,24,31,33), | |
List(0,11), | |
List(11,15,17,22,23,24), | |
List(0,2,3,5,6,7,11,12,13,24), | |
List(2,5,9,10,11,17), | |
List(19,30,31,32,33), | |
List(0,2,3,6,7,9,33), | |
List(0,2,16,17), | |
List(0,9,12,20), | |
List(0,3,7,10,17), | |
List(0,17,31,33), | |
List(0,11,17,22,23,24), | |
List(0,2,3,5,6,19,26,27), | |
List(0,2,3,9,22), | |
List(0,2,3,5,6,7,11,12,20), | |
List(0,2,3,5,6,7,11,19,20), | |
List(0,2,3,5,6,7,10,14,15,16,17,19,20,28,31,32), | |
List(0,2,3,9,10,20,26), | |
List(0,2,3,11,22,32,33), | |
List(0,2,3,11,15,20,26), | |
List(0,6,7,10,24), | |
List(0,5,7,11,17), | |
List(0,9,10,22,24), | |
List(2,5,6,9,10,22,24), | |
List(2,11,17,19,20,28), | |
List(2,5,9,10,22,24), | |
List(2,5,6,9,19,20,28), | |
List(0,9,10,11,12,13,14,15,16,17), | |
List(22,30,31,32,33), | |
List(0,2,3,18,20,30,31,32,33), | |
List(0,2,3,9,10,11,12,13,14,15,16,17,18,19,20), | |
List(0,2,3,5,6,7,9,10,11,12,13,14,15,16,17,18,19,20,22,23,24), | |
List(0,2,3), | |
List(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33) | |
) | |
private def hisWhisper(outIndex: List[Int]) = { | |
message.zipWithIndex.map {case (v, i) => | |
i match { | |
case i if outIndex.contains(i) => v | |
case _ => " " | |
} | |
}.mkString + "\n" | |
} | |
lazy val write = hesitationList.map(hisWhisper).mkString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment