This is just a silly repo that consists of code generators in different languages to see if a number is even.
python python.py 10If you want to run the generated script, run these commands instead:
-
python python.py 10 > is_even.py -
python is_even.py
x = 10
func = is_even(x, return_func=True) # This will return a callable than you can call
print(func()) # Call the function which prints 'True'Make sure you have
perlinstalled.
- Run the script generator:
perl perl.pl - 5 > is_even.plNote
The - symbol after the script is to pass the argument to the script.
If you want to pass negative number. You can do something like this:
perl perl.pl - -10 > is_even.pl- Run the generated script:
perl is_even.pl
# 0Only generate the code
lua lua.lua 9Redirect the output to lua to run it directly
lua lua.lua 9 | lua
# falseRedirect the output to a file to run it later:
lua lua.lua 9 > is_9_even.luaLater on, if you forget if 9 is even or not, just run the script:
lua is_9_even.lua
# false- Compile:
gcc c_code.c -o c_code- Usage:
# Unix
./c_code 10 > is_even.c
# Windows
.\c_code.exe 10 > is_even.c- Compile that newly baked program:
gcc is_even.c -o is_even- Check the result, is 10 even?:
# Unix
./is_even
# Windows
.\is_even.exe
# trueMake sure you have
rustupinstalled.
- Compile:
rustc rust.rs- Usage:
# Unix
./rust 10 > is_even.rs
# Windows
.\rust.exe 10 > is_even.rs- Compile that newly baked program:
rustc is_even.rs- Check the result, is 10 even?:
# Unix
./is_even
# Windows
.\is_even.exe
# trueI use fpc to compile. Use whatever free pascal compiler you have.
- Compile:
fpc pascal.pp- Usage:
# Unix:
./pascal 9 > isEven.pp
# Windows:
.\pascal.exe 9 > isEven.pp- Compile the new isEven program:
fpc isEven.pp- Run it:
# Unix:
./isEven
# Windows:
.\isEven.exe
# FALSE<head>
<import name="is even" module="if-else-is-even"/>
</head><body>
<call name="is even">1</call> # False
<print>
<call name="is even">2</call> # True
</print>
</body>$ python -m htmlish htmlish.html [--code]Options:
--code: Displays the Python-equivalent of the HTMLish code
Copy typescript.ts into your repository and import it directly. In this example, we have name the file "ifElseIsEven.ts":
import { evaluate } from "ifElseIsEven.ts";import { evaluate } from "ifElseIsEvent.ts";
function fn() {
const parityOf3 = evaluate(3); // "Odd"
const parityOf8 = evaluate(8); // "Even"
const output = `3 is ${parityOf3} and 8 is ${parityOf8}`;
console.log(output); // Prints "3 is Odd and 8 is Even"
}Caution
Calling evaluate for numbers with an absolute value > 100,000,000 will likely take at least 10 seconds to process and consume a very high amount of RAM (estimated between 40 and 80 bytes per number). The program is structured in a way that does not overflow the stack; it will continue running until it has exhausted your system's memory and may cause your runtime or operating system to crash.
- Supports negative inputs
- Does not support
Infinityor-Infinity(an error message will display) - Does not support
NaN(an error message will display) - The return type of
evaluateis a string literal - "Even" or "Odd"