How to convert a predicate from multi to det in Mercury lang?

So you're learning Mercury lang and you have a predicate with multi determinism. Maybe it looks something like this:

:- pred school(string:: in, string:: out) is multi.

fish(Fish, ParticularFish) :-
  ( append("One ", Fish, ParticularFish)
  ; append("Two ", Fish, ParticularFish)
  ; append("Red ", Fish, ParticularFish)
  ; append("Blue ", Fish, ParticularFish)
  ).

Which has four solutions …

more ...

Print a list of strings in Mercury lang

Here's a quick gist for printing a list of strings out in Mercury lang. I found that I needed this when learning the language. Maybe you do too.

Is there a better way to do this? Of course there is, I just haven't learned it yet. For example there is …

more ...

How to install Mercury lang?

Installing Mercury can be an intimidating process. Here are the steps I followed to get Mercury lang up and running.

  1. Download the latest ROTD. This tutorial uses a ROTD dated 2018-04-30, you should replace this date throughout.

  2. Uncompress the source archive

    $ tar -xzf mercury-srcdist-rotd-2018-04-30.tar.gz
    
  3. Configure the installation to …

more ...

Adding an XFCE4 terminal color scheme

This may not be the 'correct' way of doing something, but you can place your xfce4 color scheme in the following folder:

/usr/share/xfce4/terminal/colorschemes

Look at the existing files for inspiration and add a [Scheme] and Name= line to the top.

I successfully renamed terminalrc.jellybeans to …

more ...

My Program runs faster in Eclipse than on the Command line

Today in the Sunlab a student ran into a problem. His program ran faster in Eclipse than on the command line. Actually, to clarify the program initially didn't run at all on the command line. Only after increasing the heap size did it run (this should give you a hint …

more ...

Setting up a Reverse AutoSSH connection to my Dorm

Ok, you have a spare computer. You want to setup SSH. Maybe this is because your laptop is Windows and WSL doesn't yet support the Go compiler (or Elm compiler for that matter. Edit: It does now). So you want a Linux box always on in your dorm.

Problem: The …

more ...


Define Error Cases Too

When defining the interface between two sections of an application, don't forget to specify how errors are conveyed and how the receiving party can detect and handle them. Of course you should specify what errors might occur.

Notes from my mistakes...

(Note: Of course this sounds obvious, but I'll just …

more ...

Unix Fortune on Mac and Custom Fortunes

Install fortune on your mac with Homebrew.

brew install fortune

You can go ahead and start using it now, but if you want to customize your fortune files you need to know the following:

Fortune files are found in /usr/local/share/games/fortunes.

To add a new fortune file …

more ...

Msgpack vs Json in Python: Preliminary Investigation

Earlier this year in the Falcon documentation I chanced upon MsgPack. It has a pretty snazzy website you can find here. Wow, look at that! It's both smaller and faster than JSON!

I've compiled here a complete picture of the uses and disuses for the Msgpack encoding scheme. This document …

more ...