2 deleted 13 characters in body
source | link

I'm not sure how many upvotes I can expect for this, but I found it somewhat peculiar that I actually had to write that very function today. And I'm pretty sure this is the first time any .SE site sees this language (website doesn't seem very helpful atm).

ABS

def Rat pow(Rat x, RatInt y) =
    if y < 0 then
        1 / pow(x, -y)
    else case iy {
        0 => 1;
        _ => x * pow(x, y-1);
    };

Should workWorks for all rational numbers, and negative exponents and rational bases.

I highlighted it in Java syntax, because that's what I'm currently doing when I'm working with this language. Looks alright.

I'm not sure how many upvotes I can expect for this, but I found it somewhat peculiar that I actually had to write that very function today. And I'm pretty sure this is the first time any .SE site sees this language (website doesn't seem very helpful atm).

ABS

def Rat pow(Rat x, Rat y) =
    if y < 0 then
        1 / pow(x, -y)
    else case i {
        0 => 1;
        _ => x * pow(x, y-1);
    };

Should work for all rational numbers, and negative exponents.

I highlighted it in Java syntax, because that's what I'm currently doing when I'm working with this language.

I'm not sure how many upvotes I can expect for this, but I found it somewhat peculiar that I actually had to write that very function today. And I'm pretty sure this is the first time any .SE site sees this language (website doesn't seem very helpful atm).

ABS

def Rat pow(Rat x, Int y) =
    if y < 0 then
        1 / pow(x, -y)
    else case y {
        0 => 1;
        _ => x * pow(x, y-1);
    };

Works for negative exponents and rational bases.

I highlighted it in Java syntax, because that's what I'm currently doing when I'm working with this language. Looks alright.

1
source | link

I'm not sure how many upvotes I can expect for this, but I found it somewhat peculiar that I actually had to write that very function today. And I'm pretty sure this is the first time any .SE site sees this language (website doesn't seem very helpful atm).

ABS

def Rat pow(Rat x, Rat y) =
    if y < 0 then
        1 / pow(x, -y)
    else case i {
        0 => 1;
        _ => x * pow(x, y-1);
    };

Should work for all rational numbers, and negative exponents.

I highlighted it in Java syntax, because that's what I'm currently doing when I'm working with this language.