| Who | When |
Messages | |
|
|
|
| |
Messages 29-25 deleted by topic administrator between 07-10-2008 02:35 AM and 07-21-2006 08:59 AM |
| need help(socail)
|
24
|
 |
|
04-15-2006 04:37 PM ET (US)
|
|
Deleted by author 04-24-2006 11:57 AM
|
Sean O'Rourke
|
23
|
 |
|
03-04-2004 05:11 PM ET (US)
|
|
shaniqua -- Yes, you can just write a query if you want. Since a query is basically the right-hand side of a relation, you can also write a relation encoding the desired... err... relation in terms of append. If you do just write a query, make sure that your query's strategy works for all inputs, not just the ones you chose.
|
| shaniqua
|
22
|
 |
|
03-04-2004 04:27 PM ET (US)
|
|
Sean, i think your latest response is a bit confusing. I know append is already defined by prolog, yet you say we should write a relation? It's my understanding that the 11.2 asks us to use only the given append relation, and to formulate queries to do accomplish the appropriate tasks.
Essentially, we don't need to write further relations, and just need queries.
|
Sean O'Rourke
|
21
|
 |
|
03-04-2004 04:17 PM ET (US)
|
|
Beong -- no. Your solution should work for any input.
Mike -- append is already defined by your prolog. You should write a relation.
|
| mike
|
20
|
 |
|
03-04-2004 02:54 PM ET (US)
|
|
for 11.2 a) do we have to write a relation function such as third(.....) -append(..). or can we just simply use the relation given: append([], Y, Y). append([H|X], Y, [H|Z]) :- append(X, Y, Z).
and just run queries in console
|
| Beong
|
19
|
 |
|
03-04-2004 02:25 PM ET (US)
|
|
In 11.2, do we assume that we know the all the items in the list? for example, if we wanted to get the first item in a list do we do something like append([X], [b,c,d,e], [a,b,c,d,e]).?
|
Sean O'Rourke
|
18
|
 |
|
03-04-2004 02:02 PM ET (US)
|
|
Duy -- that sounds fine. You should hand in both the file containing your relations, and a transcript of the queries you used to test them. For 11.2, you should define relations, not just do queries.
|
| duy
|
17
|
 |
|
03-04-2004 11:14 AM ET (US)
|
|
how do we supposed to show our answers. Like for 11.2, you make queries. How do you supposed to write a program with it. I just load the facts, and enter the queries at the command. Is that ok? or do I have to put queries in the program itself because i tried prof example of ex.pl(or ex) it doesn't work, the one on the indoEuropean thing.
|
Sean O'Rourke
|
16
|
 |
|
03-04-2004 09:17 AM ET (US)
|
|
Shaniqua -- that is a correct example.
Omid -- remember that you can have a variable as part of a complex expression in prolog, so e.g. [1,A,2|B] means "a list consisting of '1', then something, then '2', then zero or more elements".
For part 3, it should be _easier_ to write BSTs in prolog ;). The general idea when doing data structures without assignment is to (conceptually) create a whole new copy with the necessary changes. In prolog, this looks like: modification(OldVersion, ..., NewVersion) :- ... i.e. a relation between the old and new versions of a data structure. Think of the recursive version of binary tree insertion, and try to formulate that as clauses of a relation.
autumn -- if it can't satisfy the relation, it will print out "no". If it can, it will print out a list of variable bindings, then a "?" to ask if you want more solutions. Just press enter. It should then print out "yes".
|
| autumn
|
15
|
 |
|
03-03-2004 10:49 PM ET (US)
|
|
Edited by author 03-03-2004 10:50 PM
I'm quite confused on question 11.4a say after compling by typing consult(myrelation). then I typed: myrelation([something,something], [anything,anything]). after hitting the enter what does it suppose to display?
any help will be appreciated!
|
| Omid
|
14
|
 |
|
03-03-2004 09:33 PM ET (US)
|
|
i'm lost on the last 2 problems.
most of this comes out of the fact that i dont know any prolog, so some syntax help would be nice.
prob 2: how do we go about checking seperate elements in the list
prob 3: binary search tree in prolog?!?!?!?!? this is hard enough in an imperative lang. the text gives a good example how to find an element, which i assume we should incoorporate when inserting and deleting, but how would we insert if we can't assign anything anywhere?
help is appreciated.
thanks
Omid
|
| shaniqua
|
13
|
 |
|
03-03-2004 07:30 PM ET (US)
|
|
i correct myself. a better example is [1, 2, 3, 1, 2, 3, 1, 2, 3]
|
| shaniqua
|
12
|
 |
|
03-03-2004 07:26 PM ET (US)
|
|
sean, i think your explanation of 11.2d is a bit off. You do have a string of 3 substrings, but the question asks for lists and sublists. So would a more appropriate example be [123, 123, 123]?
|
| laughter
|
11
|
 |
|
03-03-2004 07:11 PM ET (US)
|
|
Deleted by author 03-03-2004 07:15 PM
|
| Lucy
|
10
|
 |
|
03-03-2004 05:22 PM ET (US)
|
|
Do I need to implement 11.2, 11.4, and 11.5 all in prolog?
|
Sean O'Rourke
|
9
|
 |
|
03-02-2004 05:02 PM ET (US)
|
|
Edited by author 03-02-2004 05:03 PM
Alaska - Thomas is correct only for part (a). For part (c), please use my interpretation: a list is the concatenation of zero or more runs R_i of elements, where each run R(e,n) consists of n identical elements e, n >= 0. Your job is to define a relation such that a list R(e_1,n_1) ... R(e_k, n_k) is related to another list R(e_1,m_1) ... R(e_k, m_k) where m_j = 1 if n_j > 1, and m_j = 0 otherwise. In the example, "2" and "4" were not included in the output, because they were contained in runs of only a single element.
(11.2d) "abcabcabc" is a string consisting of three copies of the same substring, "abc".
|
| alaska
|
8
|
 |
|
03-02-2004 03:56 PM ET (US)
|
|
i don't understand 11.2 part d. What does it mean by " a list is a concatenation of three copies of the same sublist". What does it mean by three copies of the same sublist? Thanks
|
| alaska
|
7
|
 |
|
03-02-2004 03:38 PM ET (US)
|
|
Sean, I still don't understand your explanation. Could you tell me the difference between part a and part c. Is Thomas intepretation on part a and c correct?. Thanks
|
Sean O'Rourke
|
6
|
 |
|
03-02-2004 12:58 PM ET (US)
|
|
Edited by author 03-02-2004 12:58 PM
Lee - "relation" is the Prolog-word for "function" (more or less -- they're not the same thing). E.g. "parent(sean,peter)." defines the "parent" relation for "sean" and "peter".
TC -- I found this confusing as well. I interpret part C as "keep one copy of elements with adjacent duplicates, and no copies of anything else", e.g.
[1,1,2,3,3,4,5,5] ==> [1,3,5]
Unless someone else mentions an obviously better interpretation, let's stick with this one.
David -- you'll have to give me a bit more detail.
|
| David
|
5
|
 |
|
03-02-2004 05:47 AM ET (US)
|
|
Deleted by author 03-02-2004 06:03 AM
|
| Thomas Cunningham
|
4
|
 |
|
03-02-2004 04:33 AM ET (US)
|
|
Edited by author 03-02-2004 04:39 AM
For problem 11.4, what is the difference between part a and part c? It seems to me that the question is poorly worded.
Here's how I've interpreted it: Part a pairs [1,1,1,2,2,1,3] and [1,2,1,3]. Part c pairs [1,1,1,2,2,1,3] and [1,2,3].
In words: In part a if a cluster of atoms is encountered, keep a single copy of that atom in the position of the cluster. In part c if a cluster of atoms is encountered, keep a single copy of that atom in the position it is first encountered. Delete all other instances of that atom, even if they are not in a cluster.
This just doesn't seem correct, however.
|
| Lee
|
3
|
 |
|
03-02-2004 04:22 AM ET (US)
|
|
for 11.4 what does that mean "define relation correponing to the operation". Can anyone give me an example? thnaks a lot.
|
Sean O'Rourke
|
2
|
 |
|
03-01-2004 11:14 PM ET (US)
|
|
For those of you who were in discussion today, here's a correct and functional implementation of bubble-sort in Prolog:
bsort([],[]). bsort([A|B],[C|E]) :- bsort(B,D), bubble([A|D],[C|E]).
bubble([],[]). bubble([A],[A]). bubble([A,B|C], [A|D]) :- A < B, bubble([B|C], D). bubble([A,B|C], [B|D]) :- A >= B, bubble([A|C], D).
|
| Sean
|
1
|
 |
|
03-01-2004 10:49 PM ET (US)
|
|
How to run prolog... See http://www.cs.ucsd.edu/classes/wi00/cse130/prolog.htmlIn particular: "Type sbprolog at the prompt to start the interpreter. If your prolog code is in a file named prologCode, type consult(prologCode) to load your program. It is better to avoid . character in file names.(That is, avoid file extensions for Prolog programs.) Type control-D to exit the interpreter."
|