Scala, Java, Unix, MacOS tutorials (page 254)

Well, at least the prices are right there for you to see. :)

Here’s a quick example of how to use variable names with the Scala foldLeft method:

val pSum = movies.foldLeft(0.0)((accum, element) => accum + p1Movies(element) * p2Movies(element))

In this example the variable movies is a Seq, and the variables p1Movies and p2Movies are Map objects.

As a quick tip, this method shows one way you can find the keys that are common to two Scala Maps:

/**
 * Find the list of keys that are common to two Maps.
 */
def commonMapKeys[A, B](a: Map[A, B], b: Map[A, B]): Set[A] = a.keySet.intersect(b.keySet)

A flowchart on how to undo changes in Git, from this tweet.

This page contains examples of methods that are available on Scala sequential collections, i.e., List, Array, Vector, ArrayBuffer, and sequential collections.

Symbolic method names

The first examples will show how to use sequence methods whose names are like ++ , ++:, and so on. First, we’ll create two sample lists:

val evens = List(2, 4, 6)
val odds = List(1, 3, 5)

And here are examples of how to use these methods whose names are just symbols:

[toc hidden:1]

“The universe is made mostly of dark matter and dark energy, and we don’t know what either of them is.” (from a physics book I found at a friend’s house)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.15, “How to Flatten a List of Lists in Scala with flatten

Problem

You have a list of lists (a sequence of sequences) and want to create one list (sequence) from them.

Solution

Use the flatten method to convert a list of lists into a single list. To demonstrate this, first create a list of lists:

I’ve been working on putting together a Raspberry Pi “video streaming with camera module” system, and these are the links (and a few notes) that were helpful in the process. At the moment I’m using the “Stream video with MJPEG-streamer” approach, but it only shares images of snapshots that are taken a few times a second, so it’s not exactly what I had in mind. If I try anything next, I’ll go with the “Using nginx-rtmp” approach, which seems like it might serve up a real, live video stream.

Here are the links:

Some properties one can gain from practicing yoga, from the The Yoga Sutras of Patanjali. Think I’m going to work on “invisibility” in 2015. :)

Found a copy of the Scala Cookbook at the local Barnes & Noble. Debating about signing it before I leave.