Skip to content

Instantly share code, notes, and snippets.

@devendranaga
Created June 14, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devendranaga/47a61c4d3f85ccc69d39 to your computer and use it in GitHub Desktop.
Save devendranaga/47a61c4d3f85ccc69d39 to your computer and use it in GitHub Desktop.
#!/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