Last active
January 6, 2018 23:45
-
-
Save cryzed/57b2d01d8c13bcdcc950160decbc91bd 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
# 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