A mostly AI coded js-maker, supervised by me.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#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)))
|
||||
Reference in New Issue
Block a user