This file contains 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
class StringWithReverses(str: String) { | |
def reverseOrder(): String = { | |
var rev = new StringBuilder(str.length) | |
(0 until str.length) foreach { (i) => rev.append(str.charAt(str.length-1-i)) } | |
rev.toString() | |
} | |
def reverseCases(): String = { | |
var rev = new StringBuilder(str.length) | |
(0 until str.length) foreach { (i) => |
This file contains 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
/** | |
* Daimon.scala #8 やってみよう | |
* http://d.hatena.ne.jp/seratch2/20110507/1304777166 | |
* 以下のPlayer、Gameをそれぞれアクターとして定義して山手線ゲームをコメント例のように実行できるようにしてください。 | |
*/ | |
import actors.Actor | |
class Get | |
case class IsUsed(station: Station) |
This file contains 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
object CsvParser3 extends RegexParsers { | |
def eol = '\n' | |
def cell = "\"" ~> "[^\"]*".r <~ "\"" | |
def row = repsep(cell, ",") <~ eol | |
def headerRow = row ^^ { cells => new HeaderRow(cells) } | |
def dataRow = ( rep( ("\"" ~> "[^\"]*".r <~ "\",") | ("[^,\n]*".r <~ ",") ) ~ ( ("\"" ~> "[^\"]*".r <~ "\"\n") | ("[^,\n]*".r <~ "\n") ) ) ^^ { cells => new DataRow(cells._1 ::: List(cells._2)) } | |
def all = headerRow ~ rep(dataRow) ^^ { res => res._1 :: res._2 } | |
def parse(input: String): ParseResult[List[Row]] = parseAll(all, input) | |
} |
This file contains 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
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame) | |
@window.rootViewController = ExamMotionLayoutViewController.alloc.init | |
@window.rootViewController.wantsFullScreenLayout = true | |
@window.makeKeyAndVisible | |
return true | |
end | |
end |
This file contains 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
void dump_memory(const void* data, size_t length) { | |
const int LINE_BYTES = 16; | |
char buffer[LINE_BYTES + 1]; | |
buffer[LINE_BYTES] = 0; | |
for (int i = 0; i < length; i++) { | |
if (i % LINE_BYTES == 0) { | |
printf("%06x: ", i); | |
} |