Welcome! Log In Create A New Profile

Advanced

Assignment 2

Posted by ilanpillemer 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Assignment 2
June 22, 2008 03:25PM
Ouch..

It took me 4 hours today to get a working procedure for Question 2(a).
Yikes! Still a long way to go on this assignment.

eye popping smiley

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
avatar Re: Assignment 2
June 22, 2008 11:25PM
Hmm.. Well 2(b) was pretty similar to 2(a) so got that done relatively quickly.

Now with my solution to 2(c) if some father has only male children, but he has four male children he then appears four times as an option. And then if another father has two male children then he appears 2 times. However if a father has any non male children he does not appear at all.

Now I am not sure if that is the expected answer.. or if a male-gene father has four boys; he is only meant to be offered once as a solution.

Hmmm... I think my answer is sufficient... and I am certainly satisifed with it. grinning smiley
I had to work my way around the universal application of "not" for an uninstantiated variable to get my answer. So I feel like that was probably the main theme of the question.

Any thoughts? Though I think my answer is perfectly correct. And I will proceed onto question 3 tomorrow night.

By the way I am using GNU prolog which is slightly different to AMZI. For example I learnt that predicates are defined as dynamic by default in AMZI when they are consulted from a .pro file; but they are static by default in GNU prolog. That was a head scratched for an hour. smiling bouncing smiley

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
Anonymous User
Re: Assignment 2
June 23, 2008 09:49AM
Hi Ilan

Not sure what the question is but if you are only supposed to list a father if he has only male children then his name should only appear once and not 4 times (if he has 4 sons).


is this the bagof/setof/findall type question?
avatar Re: Assignment 2
June 23, 2008 10:34AM
Well... I implemented my own version of findall for 2(a) and 2(b) (with no googling for hints). That's why it took so long to solve. drinking smiley

It looked like the question was more interested in =.. call assertz etc

It was past midnight when I got to the point of listing the father four times instead of once. I want to implement my own code to do this and have not used the bag built-in procedures; I will use findall,bagof,setof once I know how to write implementations myself. (and this way I get to grok =..,call,assert,dynamic vs static.) The feeling when it works and you really understand completely why is a very beautiful moment worth the mental anguish.

But after your comment I will finish the job tonight. I guess I will build a stack of tested fathers so that I can check it only is collected once. And clear the stack afterwards.

In question 3 I will use setof/bagof/findall.

smileys with beer

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
avatar Re: Assignment 2
June 23, 2008 07:48PM
ok.. my procedure now only returns each father with a male gene once; no matter how many children he had. I used a stack.

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
avatar Re: Assignment 2
June 23, 2008 11:17PM
And finished question 3 this evening...
my setof version of add_element was a two line procedure. hmmm.

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
Anonymous User
Re: Assignment 2
June 25, 2008 03:47PM
yeah, the setof /bagof etc stuff is sually extremely short compared to the other ways of doing things.
avatar Re: Assignment 2
June 26, 2008 10:17PM
well finished Question 4 (implementing mergesort).. one more question to go..

But I have two other assignments (452,407) due July 14. One is going to be late.. not sure which though. Probably 407.

sad smiley

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
avatar Re: Assignment 2
June 27, 2008 12:05AM
and finished question 5.. and then made sample runs for everything... turned into a pdf...

and submitted...

Yay!

Now for COS452 Assignment 2 (after a few days break.. I will start Sunday on this)

smileys with beer

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
Anonymous User
Re: Assignment 2
June 27, 2008 11:11AM
cos407 - dr britz isn't at unisa so you migth get away with submitting her assignmet late smiling smiley
Sorry, only registered users may post in this forum.

Click here to login