Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

Not much free time today, so I’ll mix two topics. First, this morning I apparently started a new dream series in which I’m a new doctor at a medical practice. Of course I get the worst patients as a result, so that was interesting.

Next, in the movie Midnight in the Garden of Good and Evil, I was wondering what the song is that the woman at the piano (sorry I don’t know her name) starts playing when John Cusack walks by. I was guessing it was Fools Rush In by Johnny Mercer, and when I looked up that song I saw that Rosemary Clooney did a version of it. She’s in White Christmas, which is one of my favorite movies, and I also knew that she was George Clooney’s aunt. What I didn’t know is that she lived in Mayfield, Kentucky, and she’s the mother of Miguel Ferrer, who I mostly know as FBI Agent Albert Rosenfield on Twin Peaks (and two days it was Twin Peaks Day).

Miguel Ferrer as FBI Agent Albert Rosenfield on Twin Peaks

Many people seem to struggle to say things that are either pleasant or unpleasant. I can’t speak for anyone else, but having gone through the process of not knowing if I was going to live through many days in 2016, I find it easier to say pretty much anything now. It’s like you really know your time is limited. If I had died one of those times instead of just getting sick and going unconscious I wouldn’t be here now, so it’s like I got some free tickets to have fun at the circus for a little while longer.

(I suppose that sometimes when you’re dealing with the opposite sex you have to be a little careful. Today I told a woman that I liked her hair (it was tinted red-ish), but then when I got “that look” I clarified it by adding that I didn’t say that because I wanted her to come over tonight to bake some cookies, I just liked what she had done with her hair.)

~ a Facebook post from February 25, 2017

To which a friend replied:

Nothing ventured nothing gained
No more lingering doubt remained
Nothing sacred or profane
Everything to gain
Cause you’ve nothing left to lose

As I was sitting in my favorite coffee shop in Seward this afternoon, a dog walked in the back door and just stood there, looking at everyone. Owner tells me he was looking for a good poker game. ;)

~ photo from Seward, Alaska, February 25, 2011

A dog walks into a coffee shop

Lindsey: Don’t tell me you’re seeing inside them again. (long pause) What are people like, on the inside?

Jeremy: Inside most people there’s a feeling of being separate, separated from everything.

Lindsey: And?

Jeremy: And they’re not. They’re part of absolutely everyone, and everything.

Lindsey: Everything? I’m part of this tree? Part of my dog barking over fences? You’re telling me that I’m part of some fisherman in Italy, on some ocean I’ve never even heard of? There’s some guy, sitting on death row, I’m part of him, too?

Jeremy: You don’t believe me.

Lindsey: It’s hard to believe that. All of that.

Jeremy: That’s because you have this spot that you can’t see past. (Putting his finger on her forehead.) My grams and gramps had it, a spot where they were taught they were disconnected from everything.

Lindsey: So that’s what they’d see if they could? That they’re connected?

Jeremy: And how beautiful they really are. And that there’s no need to hide, or lie. And that it’s possible to talk to someone without any lies, with no sarcasms, no deceptions, no exaggerations or any of the things that people use to confuse the truth.

~ a conversation from the movie Powder

Table of Contents1 - Background: What is a Cons cell?2 - What it might look like in Scala3 - Starting to create my own Cons class4 - My second effort5 - Defining my nil value6 - Defining Cons7 - Replacing the NilCons method bodies8 - Adding a toString method to Cons9 - The complete code at this point10 - I’d really like a :: method11 - I hope that was interesting12 - See also

For some examples in my new book on functional programming in Scala I needed to create a collection class of some sort. Conceptually an immutable, singly-linked list is relatively easy to grok, so I decided to create my own Scala list from scratch. This tutorial shows how I did that.

Back to top

Background: What is a Cons cell?

The first time I learned about linked lists was in a language named Lisp. In Lisp, a linked list is created as a series of “Cons” cells. A cons cell is simple, it contains only two things:

Every year at the time of the NFL Combine I’m reminded that my hands are 10” in size, per the NFL measurement standard. I never thought of that as being particularly large, but it’s larger than guys like Patrick Mahomes, who comes in at 9.25”. That being said, he’s a great quarterback, and I’m not. :)

Per a 2015 tweet about the “Dow Joans,” Donald Trump says he should be loaded into a cannon and shot into the Sun. No excuses!

Trump says he should be loaded into a cannon and shot into the sun

Lights go out and I can’t be saved
Tides that I tried to swim against
Brought me down upon my knees
Oh I beg, I beg and plead

Come out of things unsaid
Shoot an apple off my head
And a trouble that can’t be named
A tiger’s waiting to be tamed

You are
You are

Confusion that never stops
Closing walls and ticking clocks, gonna
Come back and take you home
I could not stop, that you now know

~ from the song Clocks, by Coldplay

Mast cell disease isn’t enough, a DNA test for hemochromatosis shows that I’m a “compound heterozygote.” If you’re interested, you can find more information at

They say I got this disease from the combination of my parents DNA, but I’m guessing I got it from watching the Limitless tv series so many times. :)

Just call me a compound heterozygote (hemochromatosis)

FATHER, TALKING TO HIS SON: Life is a pain in the ass. I’ll tell ya’, you know. You work hard, try to provide for the family, and then for one minute ... everything’s good. Everyone’s well, everyone’s happy, and in that one minute you have peace.

SON: Pop ... this isn’t that minute.

~ from the movie, While You Were Sleeping

Happy Twin Peaks Day! (February 24th)

Happy Twin Peaks Day! (February 24th)
Table of Contents1 - Reading the Scaladoc2 - How I think sortInPlaceBy works3 - A sortInPlaceBy example4 - A second example5 - Discussion6 - Summary

When I first looked at the sortInPlaceBy method that was introduced on mutable sequences in Scala 2.13, I couldn’t figure out exactly what it was supposed to do.

Unable to find any examples of “scala sortInPlaceBy” on planet Earth this evening (February 23, 2020), I had to resort to some actual work, and looked at the Scaladoc.

Back to top

Reading the Scaladoc

This is what I see when I look at the Scaladoc for sortInPlaceBy on the ArrayBuffer:

def sortInPlaceBy[B](f: (A) => B)(implicit ord: Ordering[B]): ArrayBuffer.this.type

You can’t see by looking at that method what A is, so I scrolled up to the top of the page and saw this at the beginning of the Scaladoc:

My book, Functional Programming, Simplified — 4.5-star rated on Amazon — is currently on sale in three formats:

PDF Format
Just $15 on
(December sale!)

PDF version of Functional Programming, Simplified

Paperback Book
$39.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

“His name’s Chappy.”

His name’s Chappy

For me, seeing the University of Louisville (UL) and Texas A&M play this afternoon must be how it feels to see two of your kids fighting. When I went to UL I lived in the basement of the house on the left, and when I went to A&M I lived in that brick and cinder block place on the right.

As George Costanza would say, “An Al divided cannot stand.”

UL vs Texas A&M (Music City Bowl, 2015)

According to the City of Boulder, Colorado Government Facebook page, this photo from 1866 is one of the oldest known photos of Boulder, Colorado. As someone commented on that page, there are no trees shown in the area. I’m told that pretty much every tree you see in Boulder, Longmont, Louisville, Broomfield, etc., was planted by man.

Boulder, Colorado in 1866

The “Nome National Forest.” The Iditarod race ends in Nome, Alaska, somewhere near here.

If you didn’t realize it, this is actually a joke. What you’re seeing is a bunch of Christmas trees shoved into the snow on top of some sea ice.

The image comes from this Twitter page.

Nome National Forest (an Iditarod joke)

These days it’s “wisdom consultant,” not “guru.”

I found this image on the Cambridge Zen twitter page, and it looks like the image originally comes from

Wisdom consultant

Nansen and Joshu teamed up for some of the best stories in Zen literature. I’ve seen this exchange many times, but this particular translation comes from the book, Making Zen Your Own.

What is the Way? (Nansen and Joshu)