News for hackers. Stuff that matters.
Re:Push Ifs Up and Fors Down: The Idiom, Its Algebra, and It... by ismailmaj on Thursday October 08, 2026 @07:31AM (#50004549)
branchless for loop for funsies

  for (fn, n) = {
    stop = void (i) {}
    run  = void (i) { fn(i); go(i + 1) }
    go   = void (i) { *((i < n) * &run + (i >= n) * &stop)(i) }
    go(0)
  }
Or you could write all the implementations for each possible n and dispatch through a registry.

There are no comments on this comment yet.