4 languages that can kill themselves
4 files, each with a different language. Each file will call the next file, and then commit die. Like this:
**main.cpp** run main.py kill itself **main.py** run main.rb kill itself etc.
Basically how this works is each file calls 2 shell commands, one to run the next file, and one to commit toaster bath. The bash command to commit skydiving without a parachute is
I also added brief comments on how the shell commands work in each language so you might learn something.
I'm just bored.
@MohammedBalsara Okay, try to make a lexer first. A lexer takes in a string input, and turns that into a list of "tokens". A token is a class which has a type, and the actual token.
(you do python right?)
class Token: def __init__(self, type, value): self.type = type self.value = value def lexer(code): # implement your lexer here # it should return a list of tokens code = input() tokens = lexer(code) # make sure it works for token in tokens: print('[' + token.value + ']', end=' ')
A token might look like this:
token = Token('value', '5') token = Token('value', 'true') token = Token('operator', '+')
Right now, you can start small and only focus on arithmetic operations. You want your code to take in input like:
3 * (21 + 4)
And print this:
 [*] [(]  [+]  [)]
It's pretty good, but it would be cool if you could use a way to delete the files that's not the terminal, maybe os.remove() for Python (https://docs.python.org/3/library/os.html) or the file.delete command in Ruby (https://arjunphp.com/delete-file-ruby#:~:text=Removing%20single%20file%20in%20Ruby,of%20names%20passed%20as%20arguments.) Just a suggestion for in the future though, because this does its function perfectly.
i love this and
the code is too complex for me to understand also what is your fav icecream flavor?
This is absurdly daft and wonderful, wish I thought of it first.... I know the story of a man who though killing a process could be done by delete it's source program. No. Also C++ is compiled to main (the elf binary) with clang so instead of
rm main.cpp do
rm main.cpp main. There is still that cheeky main file still there.