oke.
This commit is contained in:
+11
-8
@@ -2,12 +2,15 @@
|
||||
|
||||
(require "../main.rkt")
|
||||
|
||||
;; There is no separate optimizer in js-maker 3. This demo shows the compact
|
||||
;; named-let loop output produced directly by the `js` macro.
|
||||
;; js-maker 3 does not have a separate optimizer pass. The notable direct
|
||||
;; lowering is named let to a while(true) loop with parallel updates.
|
||||
(define optimized-example
|
||||
(js
|
||||
(define (sumTo n)
|
||||
(let loop ([i 0] [acc 0])
|
||||
(if (> i n)
|
||||
(return acc)
|
||||
(loop (+ i 1) (+ acc i)))))))
|
||||
|
||||
(module+ main
|
||||
(display
|
||||
(js (define (factorial n)
|
||||
(let loop ([i n] [acc 1])
|
||||
(if (<= i 1)
|
||||
(return acc)
|
||||
(loop (- i 1) (* acc i))))))))
|
||||
(displayln optimized-example))
|
||||
|
||||
Reference in New Issue
Block a user