Show newer

@vaporeon_ @aescling @monorail yeah that's what i would do (actually I would do ++idx, ++i but it objectively doesn't matter)

@monorail @aescling this thread is justifying my current software unemployment

@monorail anyway I was nice and comfy in my bed and this made me get up to use my computer so every one of my followers better favorite this

just found out about original sin 💀 come on man

@monorail here's my final answer:

let i = 0;
for (
let idx = currentSignal.length;
i < matches[0].length && matches[0][idx] === matches.at(-1)[idx];
idx += i++
);

@vaporeon_ I was not aware of this feature!

Apparently you can create "labelled statements" for anything considered a "statement", for which I believe include for, while, switch, and if/else if/else

@vaporeon_ after a little searching someone in 2009 made a preprocessor for the language that adds goto but the library can only be found in an internet archive page and the internet archive is currently down

@vaporeon_ @alas oh I wouldn't have thought to do it with a do while, this is neat

my evil code golfing brain wants the i++ snuck into the previous line but that kind of thing tends to get you in trouble

by the way you also need i<matches[0].length in the conditional

@aescling @vaporeon_ whenever I end up writing something like that I tend to convert it to a while loop but that's just a style thing

@holly honestly I do miss being in college sometimes. I hope you have fun!

@vaporeon_ first I would try to avoid the break by having a more complicated conditional containing the logic put in the if statement

and when I have a gnarly conditional I find it easier to read in a while loop instead of a for loop since the for loop statement contains three sections

but that's all a matter of style, really

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.