Racket, 43 37 2828 26 bytes
Changelog
- Thanks to @Dadsdy for the
-2bytes. - The
-4bytes comes from converting#lang racketto#!racket. - Another
-9as I found out that language statements may go into the header of TIO, and as such, don't contribute to number of bytes. - I just learnt about Racket's
doloop!-2bytes! 🎉
Code
(let ado()(#f)(write(sleep 1))(a)) Explanation
We create a named letdo loop that actsruns infinitely. Since we used #f (false) in dos second argument, the loop won't terminate as an infinite recursive callit will only terminate if there is a #t value.
If we were to expand this out and make it more readable, it would look like this:
(letdo loop() (#f) ; (sleep 1) doesn't return anything, so #<void> will be printed. (write (sleep 1)) (loop)) The named letdo loop acts a bit similar to JavaScript's IIFE techniquewhile loop:
(functionwhile (!false) { setInterval(() =>// console.log(1), 1000);.. })();