Posts
Erik's Ponderings
Cancel

Canada the "rogue, reckless petrostate"

Oh, Canada<blockquote class="tr_bq">Over the last decade, as oil prices increased fivefold, oil companies invested approximately $160 billion to develop bitumen in Alberta, and it has finally...

"For humans, copying is learning"

Why Copying Is Fucking Awesome And Innovation Is Truly Overrated<blockquote class="tr_bq">Let me ask you something, when the first human figured out how to use fire to keep warm, what do you ...

Taxes buy civilization

How wealth of Silicon Valley’s tech elite created a world apart<div><blockquote class="tr_bq">Commuters who struggle with the crowded municipal bus service openly envy the spacious tech...

Are we in the "Great Stagnation"?

Driverless cars, pilotless planes … will there be jobs left for a human being?<blockquote class="tr_bq">Professor Tyler Cowen the future is even darker. It is not only that automation and rob...

Scala array comparison (without a PhD)

Scala collections and equality Scala collections follow a simple set of general equality rules1. Two collections are equal if: they are in the same overall category (Seq, Set, or Map) they c...

Map.map vs. Map.mapValues

I just hit a bug caused by a misunderstanding of how Map.mapValues works. Consider: val original = Map("a" -> 1, "b" -> 2) val modified = original map { case (k, v) => k -> (v + 1) } ...

Implicit conversion to the Unit type in Scala

In Scala, you have a few ways to express that a function returns the Unit type.1 A common way is to use the function syntax and specify a result type of Unit: def foo: Unit = ... Like for any re...

Getting to know CanBuildFrom (without a PhD)

Recently I needed to write a pretty simple function: given a sequence of (name, value) pairs, return a sequence of (name, some collection of all the values having that name) pairs. Here is a simple...

More iterators goodness

Following-up on the previous post about iterators, say we have a clean Scala API with Option instead: class Foo { def parent: Option[Foo] = … } def findBar(foo: Foo) = Option[Bar] = … It turns ...

Scala iterators and Iterator.iterate

There is a common programming pattern where you navigate a hierarchy in order to find an element satisfying a certain condition. I have written code like this in Java probably a million times: cla...