Welcome! Log In Create A New Profile

Advanced

Assignment 1, Question 5.

Posted by ian.coetzer 
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
Assignment 1, Question 5.
May 28, 2011 05:49AM
Hi,

The procedure that we must write should yield output like this:
if List = [a,b,c,d], the procedure order(List, Result) outputs:
Result = [(1,a), (2,b), (3,c), (4,d)].

If the input list is different - see following example - is this the desired outputmoody smiley
if List = [b,d,a,c], the procedure order(List, Result) outputs:
Result = [(3,a), (1,b), (4,c), (2,d)].

Or should it still be:
Result = [(1,a), (2,b), (3,c), (4,d)].


Also I have found examples returning something similar but like this: [[1,a], [2,b], [3,c], [4,d]] - but note it uses brackets in inner elements / lists not paranthesis? does it matter?
avatar Re: Assignment 1, Question 5.
June 01, 2011 08:51PM
They way I understand the question is:
-> the first element of the ordered pair is the position of the pair in the list, and
-> the second element of the ordered pair is the element from List in the corresponding position.

in other words if the list is the following: [q,w,e,r]
the result should be: [(1,q), (2,w), (3,e), (4,r)]
or
-> order([whatever1,whatever2,whatever3],R).
-> R = [(1 ',' whatever1),(2 ',' whatever2),(3 ',' whatever3)]
Sorry, only registered users may post in this forum.

Click here to login