mirror of
https://github.com/SirNickolas/let-utils-nim
synced 2026-01-14 21:11:43 +00:00
No description
| .github/workflows | ||
| tests | ||
| .gitignore | ||
| letUtils.nim | ||
| letUtils.nimble | ||
| License | ||
| nimdoc.cfg | ||
| Readme.md | ||
letUtils
Immutability is good. But one day I got tired of repeating variable names over and over again:
let fib = block: # OK, we are going to declare `fib`.
var fib = @[0, 1] # I already got it will be `fib`, thanks.
for i in 2 ..< 13:
fib &= fib[^1] + fib[^2]
fib # Once again? Really?
So I wrote a bunch of macros that handle the boilerplate. Now we can do this:
import letUtils
freezeVars:
var fib = @[0, 1]
for i in 2 ..< 13:
fib &= fib[^1] + fib[^2]
echo fib
assert not compiles (fib[0] = 123)
Look at the documentation for more goodies.