Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Titaniumtown
Titaniumtown / gist:c181be5d06505e003d8c4d1e372684ff
Created November 25, 2023 17:23
add_asterisks public domain
I hereby release the following code with the CC0/public domain license:
/*
EXTREMELY Janky function that tries to put asterisks in the proper places to be parsed. This is so cursed. But it works, and I hopefully won't ever have to touch it again.
One limitation though, variables with multiple characters like `pi` cannot be multiplied (like `pipipipi` won't result in `pi*pi*pi*pi`). But that's such a niche use case (and that same thing could be done by using exponents) that it doesn't really matter.
In the future I may want to completely rewrite this or implement this natively into mevel-rs (which would probably be good to do)
*/
pub fn add_asterisks(function_in: String) -> String {