#!/usr/bin/env raku sub count-common (+words) { words andthen .map: *.Bag andthen .map: *.nodemap: * ≤ 1 andthen [∩] $_ andthen .elems } multi MAIN (Bool :test($)!) { use Test; is count-common(, ), 2; is count-common(, ), 1; is count-common(, ), 0; done-testing; } multi MAIN (+words) { say count-common words».words }