1 hour ago · Tech · hide · 0 comments

In my RSS reader, I stumbled upon this code-golfed (i.e. minimised to death) snippet that's fairly clever, but from the code, utterly opaque. I couldn't immediately see how it worked, and since Copilot autocompletes most of my code for me - whether I want to or not, I figured it was a good bit of practice to decompress and understand. First things first: snooze the little copilot bastard for an hour! Side note: because I got this post through my reader, I didn't happen to clock the link right after (in the newsletter) that read "a Redditor breaks down exactly what's going on". So…um…yeah, I guess wasted energy, but probably good for my brain. Here's the original author's code: const signal = F=>(f,G=F)=>F=f?_=>f(G?.()):F?.(); // 33 bytes The crux is that it creates a wrapped stack of callbacks. Effectively recursion through locally defined (and overwritten) variables (G in this case). I started by unpacking the implicit returns so I could see more of what was going on (and renamed F…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.