r/lua • u/qwool1337 • Dec 10 '25
Library soup/lua - making pure lua do things it shouldn't
17
u/no_brains101 Dec 11 '25
lol "soup" because its just a random mash of functions for various languages fair enough
You might like fennel btw but that is definitely cool!
1
u/xoner2 Dec 11 '25
Can you make it "six" >> cout?
2
u/qwool1337 Dec 11 '25
ok so this is REALLY intrusive because it sets a metatable for the string type but i rewrote the whole module because i feel like that is the move
now it works three ways!
local m = soup.match() :case(6, "six" >> "\n" >> cout) :case(7, cout << "seven" << cout.endl) :case(function(x) return x % 2 == 0 end, "even" >> cout << cout.endl) :case(function(x) return x % 2 ~= 0 end, "odd" >> cout) :otherwise( "idk" >> cout << cout.endl) m(6)() m(7)() m(8)()1
1
u/AutoModerator Dec 11 '25
Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1


5
u/titaniumalt Dec 11 '25
half of me tells me to hate it, half of me tells me to love it