<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ## 過程做為參數 示例 ``` #lang racket ;; 計算啊到b的各整數之和 (define (sum-interagers a b) (if (> a b) 0 (+ a (sum-interagers (+ a 1) b)))) ;; 整數立方的和 (define (sum-cubes a b) (if (> a b) 0 (+ (* a a) (sum-cubes (+ a 1) b)))) ;;計算序列之和 (define (pi-sum a b) (if (> a b) 0 (+ (/ 1.0 (* a (+ a 2))) (pi-sum (+ a 4) b)))) ;;可以總結出抽象公式 ;; template: ;;(define (<name> a b) ;; (if (> a b) ;; 0 ;; (+ (<term a>) (<name> (<next> a )b)))) (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b )))) ;; 重新計算求和 (define (sum-interagers1 a b) (define (inc n) (+ n 1)) (define (identiry x) x) (sum identiry a inc b)) (sum-interagers1 1 10) ;; 重新計算立方和 (define (sum-cubes1 a b) (define (inc n) (+ n 1)) (define (sube n) (* n n n)) (sum sube a inc b )) (sum-cubes1 1 10) ;; 重新計算 pi-sum (define (pi-sum1 a b) (define (pi-term x) (/ 1.0 (* x (+ x 2))) ) (define (pi-next x) (+ x 4)) (sum pi-term a pi-next b )) (pi-sum1 1 10) ``` ## 用 ambda構造過程 `$ f(x,y)=x(1+xy)^2+y(1-y)+(1+xy)(1-y) $` `$ a=1+xy $` `$ b=1-y $` `$ f(x,y)=xa^2+yb+ab $` 方式一:輔助過程 ``` (define (f x y) (define (f-helper a b) (+ (* x (square a)) (* y b) (* a b))) (f-helper (+ 1 (* x y) (- 1 y)))) ``` 方式二: 使用lambda ``` (define (f x y) ( ((lambda (a b ) (+ (* x (square a)) (* y b) (( a b))) (+ 1 (* x y)) (- 1 y))))) ``` 方式三:使用 let ``` (define (f x y) (let ((a (+ 1 (* x y))) (b (- 1 y))) (+ (* x (square a)) (* y b) (* a b)))) ``` let的一般形式 ``` (let ((<var1> <exp1>) (<var2> <exp2>) ... (<varn> <expn>)) <body>) ``` 也可以讓 let 整體作為計算 ``` ;; 假設x=5 ;; let 中的x 賦值3 ;; 推導出結果為 33+5=38 (+ (let ((x 3)) (+ x (* x 10))) x) ``` ## 過程的作為一般性方法 ``` ;; 計算不動點 ;; 數x稱為函數∫的不動點,如果x滿足方程∫(x)=x。對于某些函數,通過從某個初始猜測 ;; 出發,反復地應用f ;; f(x),f(f(x)),f(f(f(x))),... ;; 直到值的變化不大時,就可以找到它的一個不動點 (define (fixed-point f first-guess ) (define tolerance 0.0001) (define (enough? x y) (< (abs (- x y)) tolerance)) (define (try guess) (let ((next (f guess))) (if (enough? guess next) next (try next)))) (try first-guess)) ;; 請cos 的不動點 ;; -> 0.7390547907469174 (fixed-point cos 1.0) ;; 求 y=sin y+cos y 的一個解 ;; -> 1.2586974741689445 (fixed-point (lambda (y) (+ (sin y) (cos y))) 1.0) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看