Skip to content

Instantly share code, notes, and snippets.

@cryzed
Last active January 6, 2018 23:45
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 cryzed/57b2d01d8c13bcdcc950160decbc91bd to your computer and use it in GitHub Desktop.
Save cryzed/57b2d01d8c13bcdcc950160decbc91bd to your computer and use it in GitHub Desktop.
# Here's a regular example of a predicate using numbers:
def my_predicate(item):
return item > 5
items = [5, 10, 6, 7, 7, -2]
for filtered in filter(my_predicate, items):
print(filtered)
# Output: 10, 6, 7, 7
###
# My thinking: the item export predicate looks like this
def item_export_predicate(item):
name = get_item_name(item)
matches_regex = regex_match('.+? Ore', name)
return matches_regex
# The all_items is basically provided by the item export block, you only have to provide
# the item_export_predicate function which tells the block "yes I want this item"/"no I don't want this item"
# whenever the blocks asks the predicate. all_items could look like this:
# [Diamond Ore, Diamond Ore, Redstone Block, ...]
for filtered in item_export(item_export_predicate, all_items):
print(filtered)
# Output: All blocks ending in "Ore"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment