Reply
Fri 4 Jan, 2013 05:03 pm
Define the predicate subMatrix/6 such that subMatrix(+M,+OI,+OJ,+NbLi,+NbCol,?Res) is satised if Res is a sub-matrix of M with NbLi rows and NbCol columns starting from element (OI,OJ),
meaning that element (OI,OJ) of M will be the element (1,1) of Res.
We shall thus have :
?- subMatrix([a,b,d],[d,e,f],[g,h,i]],1,2,2,2,R).
R=[[b,c],[e,f]].
?- refMatrix(M), subMatrix(M,2,1,2,3,M2).
M=[[_G1,2,_G2,4],[_G3,4,1,_G4],[2,_G5,4,_G6],[_G7,3,_G8,1]],
M2=[[_G3,4,1],[2,_G5,4]].
@angelrocksvid,
Is there a question in this? If so, what is it, and what is refMatrix?
@markr,
markr wrote:
Is there a question in this? If so, what is it, and what is refMatrix?
This is incorrectly tagged. The clue is in the title, but I expect most people born after about 1980 will not recognize it. Prolog is a weird computer programming language from the early 1970s associated with artificial intelligence and computational linguistics. The name Prolog was chosen by Philippe Roussel as an abbreviation for programmation en logique.
In Prolog, program logic is expressed in terms of relations, and a computation is initiated by running a query over these relations. Relations and queries are constructed using Prolog's single data type, the term. Relations are defined by clauses. Given a query, the Prolog engine attempts to find a resolution refutation of the negated query. If the negated query can be refuted, i.e., an instantiation for all free variables is found that makes the union of clauses and the singleton set consisting of the negated query false, it follows that the original query, with the found instantiation applied, is a logical consequence of the program. This makes Prolog (and other logic programming languages) particularly useful for database, symbolic mathematics, and language parsing applications. Because Prolog allows impure predicates, checking the truth value of certain special predicates may have some deliberate side effect, such as printing a value to the screen. Because of this, the programmer is permitted to use some amount of conventional imperative programming when the logical paradigm is inconvenient. It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features.
I said it was weird. You have to be fairly clever to get through a Prolog course, and the copying and pasting an assignment here is clearly an act of desperation.
@contrex,
I actually farted around with it for a few minutes several years ago. But since I'm not really familiar with it, I'm not sure if there is a question embedded in the post.