Trees | Index | Help |
---|
Package Bio :: Module listfns |
|
This provides useful general functions for working with lists.
Functions: asdict Make the list into a dictionary (for fast testing of membership). items Get one of each item in a list. count Count the number of times each item appears. contents Calculate percentage each item appears in a list. itemindex Make an index of the items in the list. intersection Get the items in common between 2 lists. difference Get the items in 1 list, but not the other. indexesof Get a list of the indexes of some items in a list. take Take some items from a list.Function Summary | |
---|---|
asdict(l) -> dictionary | |
contents(items) -> dict of item:percentage | |
count(items) -> dict of counts of each item | |
difference(l1, l2) -> list of items in l1, but not l2 | |
indexesof(l, fn) -> list of indexes | |
intersection(l1, l2) -> list of common items | |
itemindex(l) -> dict of item : index of item | |
items(l) -> list of items | |
take(l, indexes) -> list of just the indexes from l | |
take_byfn(l,
fn,
opposite)
|
Function Details |
---|
asdict(l)asdict(l) -> dictionary Return a dictionary where the keys are the items in the list, with arbitrary values. This is useful for quick testing of membership. |
contents(items)contents(items) -> dict of item:percentage Summarize the contents of the list in terms of the percentages of each item. For example, if an item appears 3 times in a list with 10 items, it is in 0.3 of the list. |
count(items)count(items) -> dict of counts of each item Count the number of times each item appears in a list of data. |
difference(l1, l2)difference(l1, l2) -> list of items in l1, but not l2 Return a list of the items in l1, but not l2. The list is in arbitrary order. |
indexesof(l, fn, opposite=0)indexesof(l, fn) -> list of indexes Return a list of indexes i where fn(l[i]) is true. |
intersection(l1, l2)intersection(l1, l2) -> list of common items Return a list of the items in both l1 and l2. The list is in arbitrary order. |
itemindex(l)itemindex(l) -> dict of item : index of item Make an index of the items in the list. The dictionary contains the items in the list as the keys, and the index of the first occurrence of the item as the value. |
items(l)items(l) -> list of items Generate a list of one of each item in l. The items are returned in arbitrary order. |
take(l, indexes)take(l, indexes) -> list of just the indexes from l |
Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Wed Jan 31 09:57:59 2007 | http://epydoc.sf.net |