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

“Thanks for that, Frank.” One of many funny moments in the movie, You Kill Me.

Thanks for that, Frank

This is a painting of a roadhouse in Wasilla, Alaska, circa 1957. It reminds me of living in Talkeetna. I found it on the “Last Frontier Magazine” Twitter page.

A painting of a Wasilla, Alaska roadhouse, 1957

I watched Cloud Atlas over the last few nights. It’s a long but good movie, with six sub-stories that occur over a span of hundreds of years, where you get to see the ripple of good deeds over time. (Or at least that’s one interpretation of the movie.)

Cloud Atlas: Ripples of deeds over time (one interpretation)

This book cover (nothing holy about it) has an interesting use of fonts and colors. I think I would have gone for a wee bit of transparency on the white font, and lined up the blue with the white, but it’s interesting, and essentially fits two subtitles on the cover.

Interesting use of fonts on a book cover design

May 19, 2015: Farming at 10:30pm. Photo from the Palmer, Alaska News Facebook page.

Alaska: Farming at 10:30pm

As I mentioned yesterday, I had an MRI recently, and the doctors noted that there is a lack of blood flow to three “deep white matter” locations. I think the three white spots in the middle/top of this MRI image are what they’re referring to, but I don’t know for sure yet. What I have learned is that the “gray matter” is on the outside of the brain, and the white matter is on the inside.

Dead spots in the brain: Lack of blood flow to three deep white matter locations

Tundra Comics cracks me up. Second opinion! Second opinion!

Tundra Comics - Second opinion!

I have no idea how it works, but every once in a while you’ll have dreams that come true. For example, a few years ago one of my nieces got married, and even though I didn’t go to the wedding, two nights before the wedding I had a dream of a photo that was taken, and what I saw in the dream was exactly the same as the photo, even though I have never been to the place where they were married or seen photos of the place.

(Actually there was a difference: On the far side of each row of people I saw some relatives who passed away many years ago. They were also dressed in suits and dresses.)

Then a few weeks ago I had a dream that Dr. Ruth passed away, so when I saw that she actually passed away on July 12, 2024, I asked my wife, “Didn’t you tell me that Dr. Ruth died a few weeks ago?” She said no, she didn’t say anything like that, and then I remembered that that happened in a dream.

This doesn’t happen very often, but I used to make a note of such things because I thought it was fascinating. These are just two that I can remember off the top of my head.

As a quick note to self, I wrote this Scala code as a way to (a) find the first element in a sequence and then (b) return that element without traversing the rest of the sequence.

I initially thought about writing this code with a while loop, for loop, or for expression — because I knew I needed a loop and a way to break out of a loop — but then I realized that an iterator would help me out here.

So without any further ado, here’s this solution:

“Most people treat the present moment as if it were an obstacle that they need to overcome. Since the present moment is life itself, it is an insane way to live.”

Without any introduction or discussion, here’s a little Scala script I just wrote to read in a text file that contains stocks symbols, with one symbol per line, along with some blank lines; then convert those symbols to comma-separated output (CSV format) that I print to STDOUT:

I just had this problem in Scala where I wanted to concatenate two corresponding multiline strings into one final multiline string, such that the elements from the first string were always at the beginning of each line, and the lines from the second string were always second. (When I say corresponding, I mean that the two strings are of equal length.)

That is, given two Scala multiline strings like these:

If you want to get a value out of a Scala Option type, there are a few ways to do it. In this article I’ll start by showing those approaches, and then discuss the approach of using the fold method on an Option (which I’ve seen discussed recently on Twitter).

1) Getting the value out of an Option, with a backup/default value

As a first look at getting values out of an Option, a common way to extract the value out of a Scala Option is with a match expression:

I’ve been slowly working on a series of new Scala programming books, and today I’m proud to announce the first of these:

Learn Scala 3 The Fast Way! (book cover)

Starting today you can buy the PDF version of Learn Scala 3 The Fast Way! for just ten dollars — $10 (USD) — at this URL.

Functional Programming, Simplified — currently 5-star rated on, 4.5-star rated on Amazon, and one of the all-time best-selling books on functional programming — is currently on sale in three formats (prices shown in USD):

PDF Format
$15 on

PDF version of Functional Programming, Simplified

Paperback Book
Now $29.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

If you struggle with any form of addiction AND are also interested in mindfulness and meditation — to the point of being interested in enlightenment/awakening — this quote from Daniel Ingram may be a helpful motivator:

“Stagnation is guaranteed if you cling to pleasant sensations.”

In other words, you won’t make any progress on the enlightenment path until you get past the clinging to pleasant sensations — i.e., the pleasant sensations that you are addicted to.

(A friend of mine was an addict, and I know she was also looking for any motivation to quit, so I try to share anything I learn that might be helpful.)

Sister 1: “What about that cute guy I met? Condom Man.”

Sister 2: “Yes, that’s how he likes to be known.”

Sister 3: “Condom Man? Sounds like a superhero.”

~ from the movie, Must Love Dogs

Two sisters talking in the movie, Must Love Dogs:

“So can I ask you a question?”


“You never would have left Kevin, would you?”

“If he hadn’t ... left me? No, I don’t think so.”

“But you weren’t really happy.”

“Well, I figured that was the life I picked, so I had to make the most of it. I’m not even sure I deserve a new life now. Sometimes I think that was supposed to be my one chance and I blew it.”

“Where did we get the bad attitudes?”

“The nuns?”

“Yeah, that works. Let’s blame the nuns.”

I need your grace
To remind me
To find my own.

The song, “Empty Garden (Hey Hey Johnny),” by Elton John and Bernie Taupin is one of my favorite “sad” songs, and a great tribute to John Lennon, who was one of my “peaceful” inspirations when I was growing up. In the song, I think there are at least two interpretations of the lyrics, “It's funny how one insect can damage so much grain,” and I’d like to share those here.