4 Replies - 9507 Views - Last Post: 22 November 2010 - 09:37 PM

#1 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,258
  • Joined: 27-December 08

Week #40- Prolog

Post icon  Posted 22 November 2010 - 06:54 AM

This week's challenge is Prolog, a logic-based programming language. Prolog is a declarative language which was originally designed for natural language processing, though has been used in the fields of artificial intelligence, theorem proving, games, and control systems. Rather than utilizing formal control-flow statements, Prolog allows for the definition of constraints and rules, with queries used to determine the result. Prolog also does not support formal looping, requiring recursion to implement iteration. In addition, Prolog supports higher-order programming, as well as dynamic and meta-programming, with many facilities for reflection.

Getting Started
There are a number of Prolog implementations, both commercial and for free, for various operating systems, including DOS, Windows, Mac OS, Linux, and Unix. There are also Prolog implementations for the JVM.

Some of these implementations include:

For a complete list of Prolog implementations, see the Wikipedia article

Resources and Tutorials

Ideas

Is This A Good Question/Topic? 0
  • +

Replies To: Week #40- Prolog

#2 brianarn  Icon User is offline

  • New D.I.C Head

Reputation: 11
  • View blog
  • Posts: 27
  • Joined: 02-October 09

Re: Week #40- Prolog

Posted 22 November 2010 - 08:46 AM

Prolog is a fascinating language. I had exposure to it around eight or nine years ago, as part of my CS degree at UNM. Don't know if it's still a part of 451, but I'm glad it was then (Java was too, the core [123]51s were still C++ at the time).

Prolog is also covered in Seven Languages in Seven Weeks, which basically looks to be a self-driven version of that class. It hits some other languages too, and while I haven't read it myself, I might buy it this week, as they've got a special going, use the coupon code 'turkey' to get 40% off most all of their stuff.

Seriously, if you haven't played in Prolog before - take a little time and experiment. It's such a different approach from other languages, with some fascinating and fun results. Worth playing a bit.
Was This Post Helpful? 0
  • +
  • -

#3 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Week #40- Prolog

Posted 22 November 2010 - 05:45 PM

I love prolog, one of my favorite programming languages.
Was This Post Helpful? 0
  • +
  • -

#4 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Week #40- Prolog

Posted 22 November 2010 - 05:57 PM

this is a snippet i had, its nothing fancy, just shows how to permute a list in prolog, I just wanted to post it to show everyone how small the implementation is compared to any language.

delete(X, [X|T], T).

delete(X, [H|T], [H|S]):-
	delete(X, T, S).


permutation([], []).

permutation([H|T], R):-
	permutation(T, X), delete(H, R, X).



written in SWI-prolog.

This post has been edited by mostyfriedman: 22 November 2010 - 06:47 PM

Was This Post Helpful? 0
  • +
  • -

#5 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Week #40- Prolog

Posted 22 November 2010 - 09:37 PM

SWI prolog is the best one that I've tried.

Here is a rather naive implementation of quicksort that I wrote for my programming languages class project...

% Tom Arnold <tarno1@brockport.edu>
partition(_, [], [], []).
partition(Pivot, [Item|List], Left, Right) :-
	Item >= Pivot,
	partition(Pivot, List, Left, NewRight),
	append(NewRight, [Item], Right), !.
partition(Pivot, [Item|List], Left, Right) :-	
	partition(Pivot, List, NewLeft, Right),
	append(NewLeft, [Item], Left), !.

quicksort(List, SortedList) :-
	length(List, ListLength),
	ListLength =< 1,
	SortedList = List.
quicksort([Pivot|Rest], SortedList) :-
	partition(Pivot, Rest, Left, Right),
	quicksort(Left, SortedLeft),
	quicksort(Right, SortedRight),
	append(SortedLeft, [Pivot], L1),
	append(L1, SortedRight, SortedList).


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1