Skip to content

Instantly share code, notes, and snippets.

@altbodhi
Created July 13, 2022 13:07
Show Gist options
  • Save altbodhi/98ffdbd995a272eb0afbe06ba4947be0 to your computer and use it in GitHub Desktop.
Save altbodhi/98ffdbd995a272eb0afbe06ba4947be0 to your computer and use it in GitHub Desktop.
The skip loop with Nemerle.
using System.Console;
def skip_loop(counter, skip, max, idx, lst) {
if (idx >= max) lst
else
if ( counter >= skip )
skip_loop(1, skip, max, idx + 1, idx :: lst)
else
skip_loop(counter + 1, skip, max, idx + 1, lst)
}
def r = skip_loop(1, 2, 10, 1, []).Reverse();
WriteLine($"result is ..$r");
//=> result is 2, 4, 6, 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment