Friday, March 13, 2009

Prolog on OSX

In my last post I solved a logical problem with prolog. If you want to get gprolog on your mac to play around with yourself, the easiest way to get it by far is to use macports. There are 4 very simple steps (one of them is optional even!).

Step 0:

open up the Terminal application.

Step 1 (Optional):
update your macports installation with the command:
sudo port -d selfupdate


Step 2:
upgrade your installed programs with the command
sudo port -d upgrade installed


Step 3:
install gprolog with the command
sudo port install gprolog


That's it. Now you can just type 'gprolog' to enter the prolog interactive interpreter. To load a file 'prog.pl', simply type
[prog].
into the interpreter and then you can play around with any functions/axioms defined in that file.

See my last post to look at an example prolog file, and see how to load files and use there functions.

See this post to learn how to install macports on your mac.

enjoy, everyone ^.^

Labels: , ,

Thursday, February 26, 2009

Ports!

It's been a couple months since I last formatted my computer, and I hadn't reinstalled macports until tonight. I was procrastinating because I remembered it being a pain to set up the first time. Turns out I was just a noob back then ^.^

went to the macports site and got the latest version to install. then just clicked through the install w/o any changes. It was kindof an accident. I do it a lot because I fail to see the 'customize' button in OSX installer before I click through to the next page(It's all alone in the bottom left of the window; who looks at the bottom left of windows?!). Luckily I knew that macports wants to install everything in /opt/local/bin.

All that was left was to change PATH variable to let my execute macports' apps from any directory. Another key step was to add macports' man pages to my MANPATH variable. I think that this was the part that I found confusing when I first installed macports, because I wasn't aware that MANPATH existed. None-the-less I was confused when I couldn't read man pages for the apps I ported.

yadda yadda yadda.... open my bashrc file to add these paths:
sudo vim /etc/bashrc

If you don't use vim for text-editing, I highly recommend it. To learn more you can just execute the command in the terminal:
vimtutor

The tutorial is a text file and you learn how to edit in vim it as you read it. Pretty clever, but not what we came to do.. back to bashrc.

Add the following lines to your bashrc file:
PATH="/opt/local/bin/:/opt/local/sbin/:$PATH"
MANPATH="/opt/local/man/:$MANPATH"

Save and exit your text editor(:wq in vim), and tada! All bash terminals you launch from now on will let you launch your macports apps.

To load the changes into your current terminal session type (note the space between the period and slash)
. /etc/bashrc

Thats all there is to it ^.^

Labels: , ,