Advanced Collection Pattern Matching: Multiset, Set, and Nested Join Patterns with Bitmask Optimization

The practical expressiveness of non-linear pattern matching is insufficient with basic join patterns (`xs ++ ys`) alone; order-independent collection matching is indispensable. This paper reports on the design and implementation of multiset patterns (order-independent matching with duplicates), set patterns (order-independent matching with uniqueness constraints), nested join patterns (recursive list splitting), and logical connective patterns (And/Or/Not) in the egison-patterns library. The multiset matching employs a backtracking algorithm, and the optimized implementation adopts uint64 bitmask-based O(1) index tracking. For collections of 64 elements or fewer, the bitmask approach demonstrates significant improvements in cache efficiency compared to the HashSet approach. The integration of non-linear variables with collection patterns enables natural expression of patterns such as "detecting duplicate elements in a multiset."

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-03-20
DOI
https://doi.org/10.5281/zenodo.19139116
Primary Topic
Network Packet Processing and Optimization
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Advanced Collection Pattern Matching: Multiset, Set, and Nested Join Patterns with Bitmask Optimization

Wataru MITSUDA, Inc. Gods & Golem
Zenodo (CERN European Organization for Nuclear Research)
Network Packet Processing and Optimization
article

Advanced Collection Pattern Matching: Multiset, Set, and Nested Join Patterns with Bitmask Optimization

Wataru MITSUDA, Inc. Gods & Golem
article en

Abstract

The practical expressiveness of non-linear pattern matching is insufficient with basic join patterns (`xs ++ ys`) alone; order-independent collection matching is indispensable. This paper reports on the design and implementation of multiset patterns (order-independent matching with duplicates), set patterns (order-independent matching with uniqueness constraints), nested join patterns (recursive list splitting), and logical connective patterns (And/Or/Not) in the egison-patterns library. The multiset matching employs a backtracking algorithm, and the optimized implementation adopts uint64 bitmask-based O(1) index tracking. For collections of 64 elements or fewer, the bitmask approach demonstrates significant improvements in cache efficiency compared to the HashSet approach. The integration of non-linear variables with collection patterns enables natural expression of patterns such as "detecting duplicate elements in a multiset."

Zenodo (CERN European Organization for Nuclear Research)
Openalex Percentile: Top 10%
Network Packet Processing and Optimization
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.