Created
June 14, 2015 14:07
-
-
Save devendranaga/47a61c4d3f85ccc69d39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
class Lists: | |
def __init__(self): | |
self.list = [] | |
def list_head(self): | |
return self.list[0] | |
def list_tail(self): | |
return self.list[len(self.list) - 1] | |
def list_add_tail(self, elem): | |
self.list.append(elem) | |
def list_add_head(self, elem): | |
self.list.insert(0, elem) | |
def list_remove(self, elem): | |
self.list.remove(elem) | |
def list_foreach(self, func): | |
for item in self.list: | |
func(item) | |
def list_empty(self): | |
if len(self.list) == 0: | |
return True | |
return False | |
def list_find_elem(self, elem): | |
for item in self.list: | |
if item == elem: | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment