diff --git a/neutgs/init.fnl b/neutgs/init.fnl index e413fda..030c807 100644 --- a/neutgs/init.fnl +++ b/neutgs/init.fnl @@ -20,8 +20,13 @@ (IMStartUp) (TextStartUp) -; (if (= 1 1) (printnum 1) (printnum 2)) -; (if (or (< 3 2) (not= 5 10)) (printnum 3) (printnum 4)) + (let (x 1 dx 2 lim (if (> dx 0) 10 -10) break [ssc.FALSE]) + (while (and (< x lim) (not break)) + (printnum x) + (set! x (+ x dx)) + (if (= x 6) (set! break [ssc.TRUE])))) + + (if (> (+ 1 2) (+ 3 4)) (printnum 0x1212) (printnum 0x3434)) (if (and (or (= 1 2) (< 3 4)) ; (not (or (> 10 3) (<= 6 5)))) (printnum 0xdead) (printnum 0xbeef)) diff --git a/ssc/init.fnl b/ssc/init.fnl index 560fda6..c032a00 100644 --- a/ssc/init.fnl +++ b/ssc/init.fnl @@ -32,9 +32,6 @@ ; args are either strings (symbols) or numbers ; TODO: -; * implement global definitions -; * fix comparisons -; * implement loops ; * implement "getters" (subroutine that runs when referenced by name without an explicit call) (import-macros {:sss ! : compile} :ssc.macros) @@ -242,6 +239,10 @@ cl-false (if ?iffalse [[:bra :-if-done-] :-if-false- c-false :-if-done-] [:-if-false-])] (values (lume.concat block cl-false) etype))) + :while (lambda [self test ...] + (let [block [:block :-loop-top- (self:gen-condition test :-enter-loop- :-exit-loop-) :-enter-loop-] + c-body (self:expr-poly [:do ...])] + (values (lume.concat block [c-body [:bra :-loop-top-] :-exit-loop-]) :void))) :+ (lambda [self first ...] (self:accumulation-op (fn [etype {: lo : hi : const}]