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
#!/bin/sh | |
# | |
# Trims out the bullshit "redirect me to the top-level page" Javascript that scaladoc | |
# jams into every fucking documentation page. Fucking fuckers. | |
if [ -z "$1" ]; then | |
echo "Usage: $0 somedoc.jar" | |
exit 255 | |
fi |
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
> proguard:proguard | |
[info] Updating {file:/Users/mdb/projects/codex/}codex... | |
[info] Resolving net.sf.proguard#proguard-base;4.9 ... | |
[info] Done updating. | |
[info] Compiling 32 Scala sources to /Users/mdb/projects/codex/target/classes... | |
[warn] there were 83 deprecation warning(s); re-run with -deprecation for details | |
[warn] one warning found | |
[info] ProGuard, version 4.9 | |
[info] Reading program directory [/Users/mdb/projects/codex/target/classes] | |
[info] Reading program jar [/Users/mdb/.ivy2/local/com.samskivert/samscala/1.0-SNAPSHOT/jars/samscala.jar] |
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
// Say we have a List of names and we would like to find all those names where "am" occurs: | |
{ | |
// LINQ | |
// string[] names = { "Sam", "Pamela", "Dave", "Pascal", "Erik" }; | |
// List<string> filteredNames = names.Where(c => c.Contains("am")) | |
// .ToList(); | |
// Java Streams | |
// String[] names = {"Sam","Pamela", "Dave", "Pascal", "Erik"}; | |
// List<String> filteredNames = stream(names) |
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
case class Command (name :String, callsOtherCode :Boolean) | |
case class Procedure (name :String, commands :List[Command]) | |
case class Activation (procedure :Procedure, parent :Option[Activation], returnAddress :Int) { | |
def parentCmdName :Option[String] = | |
parent map(_.procedure.commands(returnAddress)) filter(_.callsOtherCode) map(_.name) | |
} | |
def callStack (act :Activation) :List[String] = | |
List(act.procedure.name) ++ act.parentCmdName ++ act.parent.map(callStack).flatten |
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
object Euler063 extends EulerApp { | |
def count (n :Int, p :Int, c :Int) :Int = | |
if (n == 10) c | |
else if (BigInt(n).pow(p).toString.length < p) count(n+1, 1, c) | |
else count(n, p+1, c+1) | |
def answer = count(1, 1, 0) | |
} |
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
object Euler062 extends EulerApp { | |
def search (n :Long, cubes :Map[Long,List[Long]]) :Long = { | |
val cube = n*n*n | |
val key = cube.toString.sortWith(_>_).toLong | |
val perms = cube :: cubes.getOrElse(key, Nil) | |
if (perms.length == 5) perms.last | |
else search(n+1, cubes + (key -> perms)) | |
} | |
def answer = search(1, Map()) | |
} |
NewerOlder