Prolog exercise: Min and Max of a list

As a fun exercise I implemented a predicate to calculate the minimum and maximum element of a list.

min_and_max([A], A, A).
min_and_max([H|R], N, X):-
    min_and_max(R, RN, RX),
    N is min(H, RN),
    X is max(H, RX).

Next I wrote a version with last-call optimization.

min_and_max_2 …
more ...

One thing I miss from Mercury

It's been a year since I've written any Mercury (the purely logic/functional programming language), but there's one feature I miss. It's nothing fancy, and certainly one of the less interesting features Mercury has to offer.

The Problem

To understand this particular feature let's look at where other languages fail …

more ...

Redwoods

Here are some photos from Redwoods National and State Parks, an hour and a half north of Eureka, CA.

more ...

Driving to Flagstaff

A storm rolled in before I left Apple Valley.

One thing the West has that the East doesn't is independent drive-thru restaurants and beverage stands. Ever since New Mexico I've been seeing coffee trucks and smoothie wagons. I've also seen a good number of drive-thru Mexican restaurants. All of them …

more ...

Kanab, UT (round 2)

We headed out for a casual day of hiking in the Kanab region. We visited the Toadstools Hoodoos, the Belly of the Dragon, and Coral Pink Sand Dunes State Park.

The first is a short hike, with just a few cool rock formations. I was really hoping for more of …

more ...

Bryce Canyon, UT

I traveled to Bryce Canyon the 21st of February. I don't have much to say right now so here are some photos.

We went on a hike down into the canyon. It was pretty icy. Here you can see some wonderful colors between the red stone and the white snow …

more ...

Kanab, UT

Friday evening we stepped out to take in the foggy full-moon. I'm not one for superstition but the previous full moon claimed SOPHIE, this one was to claim its own victim, albeit mechanical. Unsuspecting, we spent a good half-hour watching the local cats play tag in the moonlight.

Saturday

The …

more ...

White Sands, NM

I woke up today in Carlsbad, NM. I was to drive west through the Lincoln national forest and across the Sacramento mountains. I began the day late since I was waiting for my Airbnb's dryer to finish its task.

So I headed out to La Patrona to grab a breakfast …

more ...

My Experience with Xonsh

Since January I've been using Xonsh as my main shell on both my work and personal machines. In this post I will describe what I liked and what I didn't. TLDR; I liked that I found myself scripting more under Xonsh, but it can be slow and inconvenient as a …

more ...

Cumberland, MD

Cumberland is a neat town. It's industrial like Pittsburgh but also has a colonial feel. There are churches everywhere, and in between them you'll find truck depots, train tracks, canals, earth haulers, and other elements of industry.

The city is split by a canal. Alongside it runs a walking path …

more ...