33 lines
959 B
Racket
33 lines
959 B
Racket
#lang racket/base
|
|
(require "../main.rkt")
|
|
|
|
(define examples
|
|
(list
|
|
(cons 'expression
|
|
(js/expression
|
|
(let loop ([i 0] [acc 0])
|
|
(if (< i 5)
|
|
(loop (+ i 1) (+ acc i))
|
|
acc))))
|
|
(cons 'program-t1
|
|
(js
|
|
(set! window.myfunc
|
|
(λ (x)
|
|
(let* ((el (send document getElementById 'hi))
|
|
(y (* x x)))
|
|
(send el setAttribute "x" (+ y "")))
|
|
(send console log "dit set attribute x on element hi")))))
|
|
(cons 'program-t2
|
|
(js
|
|
(define (f x)
|
|
(if (and (> x 10) (< x 15))
|
|
(begin (console.log x)
|
|
(return x))
|
|
(return (* x x))))))
|
|
(cons 'regexp
|
|
(js/expression
|
|
(regexp-match #px"([a-z]+)-([0-9]+)" "abc-123")))))
|
|
|
|
(for ([e (in-list examples)])
|
|
(printf "===== ~a =====\n~a\n\n" (car e) (cdr e)))
|