%actor = ( merlyn=>1, kudra=>1, ovid=>1, badguy=>1 ); %thing = ( gold=>50, pocketLint=>0.01, cheapWhiskey=>-20, dominationFund=>10E10 ); \$actor{merlyn}{owns} = {gold=>1}; \$actor{kudra}{owns} = {dominationFund=>1}; \$actor{ovid}{owns} = {pocketLint=>1, cheapWhiskey=>1}; ##```## \$x = any(\$actor); \$y = any(\$thing); &rich(\$x) if (&owns(\$x,\$y) and &isvaluable(\$y)); ##``````## if (\$x{owns}{\$y} && \$thing{\$y}{value}>20) { print "The badguy will steal \$x\'s \$y.\n"; } if (\$item{value} > 20) { print "The badguy will steal from \$potentialvictim\n"; } if ( \$(any(@{\$x->{owns}})){value} > 20) { print "badguy will steal from \$x\n"; } \$isvaluable = sub (\$) { my \$x=shift; \$x->{value} > 20 ? 0 : 1; }; ##``````## \$x = wave(keys %actor); \$y = wave(keys %thing); \$item = wave(\$actor{\$x}{owns}->{\$y}); ##``````## sub wave { # given an array, return entanglement of elements my @k = @_; my \$n; foreach (@k) { push(@n,(1,\$_)); } # every element is 100% probable return entangle @n; } ```