# Advent of Code 2025, day 6, part 1 -- if-while test set 'noop {return nil} # Usage: if conditional {case1} {case2} set 'if { inset args '(_if_cond _if_true _if_false) # Mass-assign sugar set '_if_pair [return noop, return _if_false] set '_if_pair [ get _if_pair (to-int (to-bool _if_false)) return _if_true ] (get _if_pair (to-int (to-bool _if_cond))) # Extra () means execute } # Usage if {conditional} {case} set 'while { inset args '(_while_cond _while_true) set '_while_pair [return noop] push _while_pair [ # Construct fn as data so we don't have to think about return [make-quote _while_true] # ..variable shadowing when recursing return [return 'while, make-quote _while_cond, make-quote _while_true] ] (get _while_pair (to-int (to-bool (_while_cond)))) }
https://files.mastodon.social/media_attachments/files/114/310/103/102/902/781/original/54dec10db669c1ed.png