So one chapter of the 7 languages in 7 weeks book was Prolog. Yeah, it’s an older language but it s really fun. Since i ve been doing imperative style programming for so long it was quite literally mind-bending. It kept me up late playing like I used to with Java way back in the late 90s, in other words it was freakin fun. At any rate, I won t regurgitate any summaries of Prolog (there are plenty), but i will leave some code examples.
The example listed below was a totally simple program designed to return the smallest integer from a list (totally basic I know), but what i m also including here is the unit test and command line version too just for the hell of it.
file d2_2.pl
file test_d2_2.pl
file cmd_d2_2.pl
So, yeah, i know that’s totally simple but for people just starting out it might prove useful.
I think for Prolog to be a tool that I would choose I d have to be using it for months first. It s kind of the chicken and the egg problem unfortunately. If i had a lot of spare time between work/child/running I would work on building stuff with Prolog but i m not sure that will happen. If i do write something however I will post it.
Oh, BTW, this wasn’t the only Prolog thing we did. We did the standard fibonacci and factorial problems as well as the standard map coloring problem (couldn t write that myself - need more practice.) but i won t include the code here.
Comments