Nodes/ComfyUI-YogurtNodes/ListBinaryOps (Yogurt Nodes)
ComfyUI Node

ListBinaryOps (Yogurt Nodes)

One node for union, intersection, zips, and every other two-list trick

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
ListBinaryOps (Yogurt Nodes)
  • list_a
  • list_b
  • fill_value
  • result
  • count
operationunion
concat
key
start_index0
end_index-1
other_start_index0
range_length-1
sort_reversefalse

Lists are the workhorse data type of any batch workflow, and once you have two of them you immediately want to combine them - merge, dedupe, find what's in both, pair them up. ListBinaryOps is the kitchen drawer that holds all of it: twenty-one binary operations on two lists behind a single dropdown, from union and intersection to zip, splice, swap_ranges, and even elementwise math.

It's a logic node in the YogurtNodes pack (yogurt7771/ComfyUI-YogurtNodes), and it's the node that saves you from installing a different list-utility pack just to get one set operation.

How it works

Two required inputs, list_a and list_b (any list-like thing - it coerces iterables to lists), plus an operation dropdown. The results:

  • Set ops: union (deduped merge), intersection, difference, symmetric_difference, plus _unique and _sorted variants. These preserve order and handle duplicates sensibly - intersection counts occurrences, intersection_unique doesn't.
  • Zip family: zip (pairs up, truncating), zip_longest (pads with fill_value), zip_repeat (cycles the shorter list), and zip_concat / zip_longest_concat which join each pair into a string with your concat connector - great for building "prompt:strength" style strings from parallel lists.
  • Structural: cartesian_product, interleave (weave two lists), splice (replace a slice of A with B using start_index/end_index), swap_ranges (swap a slice of A with a slice of B), and merge_dicts / merge_with_key for when your lists are dicts.
  • Math: elementwise_add/sub/mul - because [1,2,3] + [4,5,6] being concatenation in Python and you wanting it added elementwise is exactly the kind of thing a node graph makes clear.

Every operation returns result and count (the length), so you get the length for free - no separate size node needed.

Inputs that matter

  • operation - the dropdown. Start with the set ops; explore the rest when a workflow needs them.
  • list_a, list_b - the two inputs.
  • fill_value - needed for zip_longest and interleave padding.
  • concat - the connector for zip_concat variants.
  • start_index / end_index / other_start_index / range_length - only used by splice and swap_ranges.

Install

Pack-wide routine - ComfyUI Manager (search "YogurtNodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt

Restart, find it under Yogurt Nodes / Logic. No extra dependencies.

Troubleshooting

  • "union is dropping my duplicates." That's not a bug - union is dedupe-by-design. If you want concatenation-with-duplicates, that's ListConcat's job, not union's.
  • "My lists aren't sortable." union_sorted needs comparable elements; mixed types (numbers + strings) throw. Use plain union instead.
  • splice with end_index = -1 inserts rather than replaces - that's documented behavior, but it surprises people the first time. And range_length = -1 on swap_ranges auto-matches the shared space, so you don't have to count manually.
  • A wrong operation silently does the wrong thing. The dropdown is all power. If output looks sane but wrong, double-check you didn't pick difference when you wanted symmetric_difference - the names are close, the results are not.

The honest review: you won't use all twenty-one ops. But the set operations and the zip variants are genuinely useful, and having them in one node beats a drawer of single-purpose list utilities. It's the list node I'd reach for before installing another pack.

CategoryYogurtNodes/Logic

Inputs (11)

NameTypeDefaultDescription
operationCOMBOunionBinary operation to apply to the two inputs.
list_a*First list-like input.
list_b*Second list-like input.
fill_valueopt*Padding value for zip_longest variants and interleave.
concatoptSTRINGConnector inserted between paired elements for concat variants.
keyoptSTRINGDictionary key used by merge_with_key.
start_indexoptINT0-2147483648–2147483647Start index used by splice and swap_ranges.
end_indexoptINT-1-2147483648–2147483647Exclusive end index for splice. Use -1 to insert only.
other_start_indexoptINT0-2147483648–2147483647Start index in list_b for swap_ranges.
range_lengthoptINT-1-1–2147483647Range length for swap_ranges. -1 auto-matches shared space.
sort_reverseoptBOOLEANfalseReverse sorting for union_sorted.

Outputs (2)

NameTypeDescription
result*
countINT