Alles aangepast.
This commit is contained in:
+11
-14
@@ -1,16 +1,13 @@
|
||||
#lang racket/base
|
||||
|
||||
(require "../main.rkt")
|
||||
(displayln "--- and ---")
|
||||
(displayln (js/expression (and (> x 10) (< x 15))))
|
||||
(displayln "--- t2 ---")
|
||||
(displayln (js (define (f x)
|
||||
(if (and (> x 10) (< x 15))
|
||||
(begin (console.log x)
|
||||
(return x))
|
||||
(return (* x x))))))
|
||||
(displayln "--- let* ---")
|
||||
(displayln (js (let* ((x 10)
|
||||
(y (+ x x)))
|
||||
(return y))))
|
||||
(displayln "--- let* tdz ---")
|
||||
(displayln (js/expression (let ([x 4]) (let* ([x x] [y x]) (+ x y)))))
|
||||
|
||||
;; There is no separate optimizer in js-maker 3. This demo shows the compact
|
||||
;; named-let loop output produced directly by the `js` macro.
|
||||
(module+ main
|
||||
(display
|
||||
(js (define (factorial n)
|
||||
(let loop ([i n] [acc 1])
|
||||
(if (<= i 1)
|
||||
(return acc)
|
||||
(loop (- i 1) (* acc i))))))))
|
||||
|
||||
Reference in New Issue
Block a user