Holy Syntactic Sugar Batman

I’ve never written any Scala code before today, but it has Python-esque mapping methods and ranges that enable you to do some things in very little code. For example, this code instantiates an array of vertex objects each containing an array of edge objects from a CSR (off, ind, wgt) graph:

val verts = (0 until nv).map{ v : Int => (v, v, 1.0/nv, (off(v) until off(v+1)).map{ e => (ind(e), wgt(e)) }, true)}

This is all for a project I’m doing at GTRI to benchmark a load of graph analysis packages and graph databases.  The specific code is for Bagel.  You can learn more here.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.