- Install stable Rust
git clone https://github.com/mpgarate/meowth.git && cd meowth
- Access the REPL with
cargo run
// pokemon [0-9]+
// battle win|lose
meowth :: win ? 111 : 222
=> 111
meowth :: lose ? 111 : 222
=> 222
A pokeball
is a container that can store pokemon or battle values. You can think of it like a const binding.
meowth :: pokeball mew = 151;
=> ()
meowth :: pokeball pikachu = 25;
=> ()
Use a pokedex()
get information on a pokemon or battle. The result is printed to stdout.
meowth :: pokedex(mew);
151
=> ()
Most pokemon can only say their own name. Use speak()
to print a bound variable name.
meowth :: speak(pikachu);
pikachu
=> ()
bike
is a variable binding which can be borrowed. The original value can be given back someday (but usually isn't). It behaves like a stack.
meowth :: bike b = 5;
=> ()
meowth :: b = 3;
=> ()
meowth :: b
=> 3
meowth :: give(b)
=> 3
meowth :: b
=> 5
An attack
is a powerful construct for reusing meowth expressions.
meowth :: pokeball mew = 151;
=> ()
meowth :: attack gnaw(n) { n - 10 };
=> ()
meowth :: pokeball kabutops = gnaw(mew);
=> ()
meowth :: kabutops
=> 141
meowth :: gnaw(kabutops)
=> 131
meowth :: attack fib(n) { n draws 0 ? 0 : (n draws 1 ? 1 : fib(n - 1) + fib(n - 2)) };
=> ()
meowth :: fib(10)
=> 55
Sometimes it is useful to repeat an expression. For this we can use a defend loop.
meowth :: bike i = 0;
=> ()
meowth :: defend (10 beats i) { i = i + 1; pokedex(i); };
1
2
3
4
5
6
7
8
9
10
=> ()
battle (pikachu beats mew) {
pokedex(pikachu);
} rebattle (mew draws pikachu) {
pokedex(mew);
pokedex(pikachu);
} rebattle (mew survives pikachu) {
pokedex(mew);
} run {
pokedex(pikachu);
}
Does something like this:
if (pikachu > mew) {
print(pikachu);
} else if (mew == pikachu) {
print(mew);
print(pikachu);
} else if (mew >= pikachu) {
print(mew);
} else {
print(pikachu);
}
Meowth is a hack based on boxx.