Projects & Stories

Regex lexer for pygments

photo_small I am currently writing on my thesis about malicous detection systems and started using indirectly pygments with latex. I am pretty happy with it since it supports all kind of text/code highlighting. That was why I was a bit surprised when I saw that there was nothing for plain old regular expressions. Normally I would create a pull request for such things but I am currently a bit short of time and this is far from being perfect. Still I want to s []

Scala: Sum up values in a Map

photo_small Some addition to my previous code snippet post. scala> val m = Map("k1" -> 1.6, "k2" -> 2.2) m: scala.collection.immutable.Map[java.lang.String,Double] = Map(k1 -> 1.6, k2 -> 2.2) scala> m.foldLeft(0.0){ case (a, (k, v)) => a + v } res16: Double = 3.8000000000000003 Instead of pattern matching you can also use the underscore solution: scala> m.foldLeft(0.0)(_+_._2) res40: Double = 3.8000000000000003 The []