Sunday, 3 April 2011

Compare lists function:


Syntax: compare(list,list)
    WARNING: AN EMPTY LIST NAMED "c" MUST BE CREATED BEFORE CALLING THIS FUNCTION WITH THE: "c = []" COMMAND
  
This compares two lists and finds the first common element in both the lists..
It returns 1 if a match is found or 0 if a match is not found in the 2 input lists..
If a match is found, it stores the match in a list "c".. If called repeatedly on different lists, it will store all the matches in list "c"..'''

Eg:
import shortestpath as sp
a = [1,2,3,4]
b= [5,6,7,2]
sp.compare(a,b)


This example will return 1.. also it will create a list c in which the number 2 will be present.


You can download the shortestpath module here:



http://www.4shared.com/file/Ysb5ADzo/shortestpath.html




Now paste this file in your home directory if you are using linux, or in your python directory, in windows wherever you have installed python. Details on all the available in-built functions so far in the shortest path module will be followed in subsequent posts.

No comments:

Post a Comment