<commit_before>class Rat {
    has $.numerator;
    has $.denominator;

    multi method new(Int $numerator is copy, Int $denominator is copy) {
        if $denominator < 0 {
            $numerator = -$numerator;
            $denominator = -$denominator;
        }
        self.bless(*, :$numerator, :$denominator);
    }

    multi method Str() { "$!numerator/$!denominator"; }

    multi method Num() { $!numerator + 0.0 / $!denominator }
}

multi sub infix:<+>(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.denominator + $b.numerator * $a.denominator,
            $a.denominator * $b.denominator );
}

multi sub infix:<+>(Rat $a, Int $b) {
    Rat.new($a.numerator + $b * $a.denominator, $a.denominator);
}

multi sub infix:<+>(Int $a, Rat $b) {
    Rat.new($a * $b.denominator + $b.numerator, $b.denominator);
}

multi sub infix:<->(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.denominator + $b.numerator * $a.denominator,
            $a.denominator * $b.denominator );
}

multi sub infix:<->(Rat $a, Int $b) {
    Rat.new($a.numerator - $b * $a.denominator, $a.denominator);
}

multi sub infix:<*>(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.numerator, $a.denominator * $b.denominator);
}

multi sub infix:</>(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.denominator, $a.denominator * $b.numerator);
}

multi sub infix:<div>(Int $a, Int $b) {
    Rat.new($a, $b);
}

# vim: ft=perl6 sw=4 ts=4 expandtab
<commit_msg>Fix Rat.Num.<commit_after>class Rat {
    has $.numerator;
    has $.denominator;

    multi method new(Int $numerator is copy, Int $denominator is copy) {
        if $denominator < 0 {
            $numerator = -$numerator;
            $denominator = -$denominator;
        }
        self.bless(*, :$numerator, :$denominator);
    }

    multi method Str() { "$!numerator/$!denominator"; }

    multi method Num() { $!numerator.Num / $!denominator.Num }
}

multi sub infix:<+>(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.denominator + $b.numerator * $a.denominator,
            $a.denominator * $b.denominator );
}

multi sub infix:<+>(Rat $a, Int $b) {
    Rat.new($a.numerator + $b * $a.denominator, $a.denominator);
}

multi sub infix:<+>(Int $a, Rat $b) {
    Rat.new($a * $b.denominator + $b.numerator, $b.denominator);
}

multi sub infix:<->(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.denominator + $b.numerator * $a.denominator,
            $a.denominator * $b.denominator );
}

multi sub infix:<->(Rat $a, Int $b) {
    Rat.new($a.numerator - $b * $a.denominator, $a.denominator);
}

multi sub infix:<*>(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.numerator, $a.denominator * $b.denominator);
}

multi sub infix:</>(Rat $a, Rat $b) {
    Rat.new($a.numerator * $b.denominator, $a.denominator * $b.numerator);
}

multi sub infix:<div>(Int $a, Int $b) {
    Rat.new($a, $b);
}

# vim: ft=perl6 sw=4 ts=4 expandtab

{'fraction_non_alphanumeric': 0.19546247818499127, 'fraction_numerical': 0.0034904013961605585, 'mean_word_length': 2.920656634746922, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '5480102', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1171, 'n_words': 246}