Scheme] |
(define (plot l) (stree->tree l)) |
Scheme] |
(plot ‘(frac 1 2)) |
Scheme] |
(plot ‘(point 0 0)) |
Scheme] |
(plot ‘(graphics (point "-5" "-5") (point "5" "5"))) ; quasiquote ‘ |
Scheme] |
(plot ‘(graphics (point ,(number->string (+ 1 2)) ,(number->string (+ 1 3))) (point 0 0))) |
Scheme] |
(plot ‘(graphics (point "0" "0") (point "1" "1") (line (point "0" "0") (point "1" "1"))))) |
Scheme] |
(plot ‘(cline (point 0 0) (point 3 0) (point 0 4))) |
Scheme] |
(kbd-map ("d i a n var" (insert (utf8->cork "点")))) |
Scheme] |
(kbd-map ("h t var" (insert (utf8->cork "绘图")))) |
Scheme] |
(kbd-map ("t u var" (insert (utf8->cork "图")))) |
Scheme] |
(kbd-map ("s j x var" (insert (utf8->cork "三角形")))) |
Scheme] |
(kbd-map ("z s j x var" (insert (utf8->cork "正三角形")))) |
Scheme] |
(define (scm2stm x) (define (x->string x) (cond ((number? x) (number->string x)) ((list? x) (scm2stm x)) (else x))) (if (eq? () x) () (cons (x->string (car x)) (scm2stm (cdr x)))))) |
Scheme] |
(define (绘图 x) (stree->tree (scm2stm x))) |
Scheme] |
(define (点 x y) ‘(point ,x ,y)) |
Scheme] |
(define (图 . objects) (cond ((nlist? objects) '(graphics "" "")) ((== objects '()) '(graphics "" "")) (else ‘(graphics "" ,@objects)))) |
Scheme] |
(绘图 (图 (点 1 1) (点 2 2))) |
Scheme] |
(define (triangle x y z) ‘(cline ,x ,y ,z)) |
Scheme] |
(define (三角形 x y z) (triangle x y z)) |
Scheme] |
(绘图 (三角形 (点 0 0 ) (点 0 3) (点 4 0))) |
Scheme] |
(car (cdr (cdr (点 1 2)))) ; third |
Scheme] |
(car (cdr (点 1 2))) ; second |
Scheme] |
(list-ref (list 1 2 3 4 5) 1) |
Scheme] |
(define (正三角形 A a) (三角形 A (点 (+ a (second A)) (third A)) (点 (+ (* 0.5 a) (second A)) (+ (third A) (* (sqrt 0.75) a)))))) |
Scheme] |
Scheme] |
(scm2stm (正三角形 (点 0 0) 3)) |
Scheme] |
(绘图 (正三角形 (点 0 0) 3)) |
Scheme] |
Scheme] |
(define (square x) (* x x)) |
Scheme] |
(define (smallest-divisor n) (find-divisor n 2)) |
Scheme] |
(define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n) test-divisor) (else (find-divisor n (+ test-divisor 1))))) |
Scheme] |
(define (divides? a b) (= (remainder b a) 0)) |
Scheme] |
(define (prime? n) (= n (smallest-divisor n))) |
Scheme] |
(prime? 7) |
Scheme] |
(smallest-divisor 7) |
Scheme] |
(find-divisor 7 2) |
Scheme] |
Scheme] |
(define (square x) (* x x)) |
Scheme] |
(define (expmod base exp m) (cond ((= exp 0) 1) ((even? exp) (remainder (square (expmod base (/ exp 2) m)) m)) (else (remainder (* base (expmod base (- exp 1) m)) m)))) |
Scheme] |
(define (fermat-test n) (define (try-it a) (= (expmod a n n) a)) (try-it (+ 1 (random (- n 1))))) |
Scheme] |
(define start 0) |
Scheme] | (debug-message "std" "\nHello\n") |
Scheme] |
(define (show-time msg ts) (debug-message "std" (string-append msg (number->string (- (texmacs-time) ts)) "\n"))) |
Scheme] |
(define (fast-prime? n times ts) (cond ((= times 0) (begin (show-time "true time: " ts) #t)) ((fermat-test n) (fast-prime? n (- times 1) ts)) (else (begin (show-time "false time: " ts) #f)))) |
Scheme] |
(define (wrap-prime? n times) (fast-prime? n times (texmacs-time))) |
Scheme] |
(wrap-prime? 99999787 100000) |
Scheme] |
(current-time) |
Scheme] |
(define start (current-time)) |
Scheme] |
(define end (current-time)) |
Scheme] |
(- end start) |
Scheme] |
(texmacs-time) |
Scheme] |
(texmacs-time) |
Scheme] |
墨者百科:https://gitee.com/XmacsLabs/tmmlwiki/raw/main/数学/费马小定理.tm