Plange


intToString.pge

<Int → String> intToString := (i) {
    <Int> register ← i;
    if (i < 0) {
        register ← -i;
    };
    <String> result ← "";
    while (register > 0) {
        digit := register  % 10;
        result ← chr(digit + 48) + result;
        register ← register / 10;
    };
    if (i < 0) {
        result ← "-" + result;
    };
    return result;
};


<Int * Int → String> coordsToString := (x, y) {
    return "(" + intToString(x) + ", " + intToString(y) + ")";
};

<a * (a → String) → String> meta := (<a> i, func) {
    return func(i);
};

copyright © Brent Lewis 2017