This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* Sample | |
forward :8087/jenkins to :8080/jenkins. | |
In product,the entityPort can be 80,so u can access jenkins | |
by http://yourhostname/jenkins | |
Good Luck! All Done Just By NodeJS! | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (count-change amount) | |
(cc amount 5 0) | |
) | |
(define (cc amount kinds-of-coins depth) | |
(define from-node (cc-node-depth amount kinds-of-coins depth)) | |
(display (cc-node-depth-label amount kinds-of-coins depth)) | |
(cond | |
((= amount 0) 1) | |
((or (< amount 0) (= kinds-of-coins 0)) 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (count-change amount) | |
(cc amount 5 0) | |
) | |
(define (cc amount kinds-of-coins depth) | |
(define from-node (cc-node-depth amount kinds-of-coins depth)) | |
(display (cc-node-depth-label amount kinds-of-coins depth)) | |
(cond | |
((= amount 0) 1) | |
((or (< amount 0) (= kinds-of-coins 0)) 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define logB | |
(lambda (x B) | |
(/ (log x) (log B)))) | |
(define (log3 x) | |
(logB x 3) | |
) | |
; (log3 9) -> 2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ref: http://community.schemewiki.org/?sicp-ex-1.17 | |
(define (fast-mult-by-add a b) | |
(define (double x) (+ x x)) | |
(define (halve x) (/ x 2)) | |
(define (helper a b product) ;; "add a" b times | |
(cond ((= b 0) product) | |
((even? b) (helper (double a) (halve b) product)) | |
(else (helper a (- b 1) (+ a product))))) | |
(helper a b 0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SampleReply: Codable { | |
let code: Int32 // 状态码 | |
private let _pageToken: String | |
lazy var pageToken: Int64 = { return Int64(self._pageToken) ?? 0 }() | |
private enum CodingKeys: String, CodingKey { | |
case code | |
case _pageToken = "pageToken" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (my-gcd a b) | |
(if (= b 0) | |
a | |
(gcd b (remainder a b))) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (p) (p)) | |
(define (test x y) | |
(if (= x 0) | |
0 | |
y) | |
) | |
; 应用序求值(先求值参数而后应用), 会陷入死循环; 正则序求值(完全展开而后归约), 会输出0. | |
(test 0 (p)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;费马小定理: 如果 n 是一个素数, a是小于n 的任意正整数, 那么 a的n次方 与 a 模n同余(除以 n 的余数相同). | |
; 计算一个数的幂, 对另一个数取模的结果. | |
(define (fermat-test n) | |
(define (try-it a) | |
; 因为 a 小于n, 所以 a/n 的余数就是 a. | |
(= (expmode a n n) a) | |
) | |
(try-it (+ 1 (random (- n 1)))) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 书上的初版实现 | |
(define (expmode base exp m) | |
(cond ((= exp 0) 1) | |
((even? exp) | |
(remainder (square (expmode base (/ exp 2) m)) m)) | |
(else | |
(remainder (* base (expmode base (- exp 1) m)) m)) | |
) | |
) |
OlderNewer