<commit_before># http://perl6advent.wordpress.com/2011/12/04/traits-meta-data-with-character/

use v6;
use Test;
plan 2;

# this gets called when 'is Cached' is added
# to a routine
our %cache;
multi sub trait_mod:<is>(Routine $r, :$Cached!) {
    #wrap the routine in a block that..
    $r.wrap(-> $arg {
	# looks up the argument in the cache
	%cache{$arg}:exists
	    ?? %cache{$arg}
            # ... and calls the original, if it
            # is not found in the cache
	    !! (%cache{$arg} = callwith($arg); 	say $arg => %cache{$arg}; %cache{$arg})
        }
    );<commit_msg>removed stray 'say' - was breaking TAP<commit_after># http://perl6advent.wordpress.com/2011/12/04/traits-meta-data-with-character/

use v6;
use Test;
plan 2;

# this gets called when 'is Cached' is added
# to a routine
our %cache;
multi sub trait_mod:<is>(Routine $r, :$Cached!) {
    #wrap the routine in a block that..
    $r.wrap(-> $arg {
	# looks up the argument in the cache
	%cache{$arg}:exists
	    ?? %cache{$arg}
            # ... and calls the original, if it
            # is not found in the cache
	    !! (%cache{$arg} = callwith($arg))
        }
    );
{'fraction_non_alphanumeric': 0.15478260869565216, 'fraction_numerical': 0.019130434782608695, 'mean_word_length': 2.7129032258064516, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1857100', 'n_tokens_mistral': 415, 'n_tokens_neox': 392, 'n_words': 125}