filter

Description

Apply a lambda function to filter out elements of a list.

 list filter( list input , lambda definition )

Evaluates a lambda for every element in the list, and returns a new list with only the elements that evaluated to true.

If you are filtering on a data feed, you should instead use filter_content() to preserve the location of items that were pinned to specific feed locations with Recommendation Manager.

Examples

Include only those items that are greater than 2:

{content = filter([1, 2, 3, 4, 5], lambda x: x>2)} ---> [3, 4, 5]
Filter out pieces of content that are tagged “explicit-content”, including pinned items:
{content = filter(content, lambda x: !contains(x.tags, 'explicit-content'))}

Note that if you are filtering on a data feed, filter_content() works the same way as filter(), but preserves pinning locations. See filter_content() for additional feed filtering examples.

Top