unroll

unroll for-loops (and map into seq/array) at compile-time in nim

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:23

Installation

nimble install unroll
choosenim install unroll
git clone https://github.com/choltreppe/unroll

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
unroll - - - - - - -

Source

Repository https://github.com/choltreppe/unroll
Homepage https://github.com/choltreppe/unroll
Registry Source nimble_official

README

Example

unroll

for i, v in unroll([2, 3, 4]):
  echo i, ": ", v

gets expanded to:

block:
  echo 0, ": ", 2
block:
  echo 1, ": ", 3
block:
  echo 2, ": ", 4

unrollMapSeq

unroll directly into a seq

let arr =
  for v in unrollMapSeq([4, 5, 6]):
    v + 2

gets expanded into:

let arr = @[
  (4 + 2),
  (5 + 2),
  (6 + 2)
]

works with any type of loop:

const arr2 =
  for v in unrollMapSeq('a' .. 'c'):
    v & "1"

unrollMapArray

works exactly like unrollMapSeq but produces an array