diff -r 3c1107984b41 -r 317a2532c567 scala/lib.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scala/lib.scala Thu Feb 21 16:07:40 2013 +0000 @@ -0,0 +1,20 @@ +package object lib { + +//some list functions +def tl[A](xs: List[A]) : List[A] = xs match { + case Nil => Nil + case x::xs => xs +} + +def hd[A](xs: List[A]) : A = xs.head + +def nth_of[A](xs: List[A], n: Int) = + if (n <= xs.length) Some(xs(n)) else None + +//some map functions +def dget(m: Map[Int, Int], n: Int) = m.getOrElse(n, 0) + +//some string functions +def join[A](xs: List[A]) = xs.foldLeft("")(_.toString + _) + +}