3.1.2 代入を取り入れた利点






(use srfi-27)
(define (random num)
  (* (random-integer num) 1.0))

(define (random-in-range low high)
  (let ((range (- high low)))
    (+ low (random range))))
(define (estimate-integral P x1 x2 y1 y2 trials)
  (define in-circle
    (monte-carlo trials
                 (lambda ()
                   (P (random-in-range x1 x2)
                      (random-in-range y1 y2)))))
  (* in-circle (* (- x2 x1) (- y2 y1))))

;; 単位円からPIを求める
(define (estimate-pi2 trials)
  (define (P x y)
    (<= (+ (* x x) (* y y)) 1))
  (estimate-integral P -1 1 -1 1 trials))



↓のページを参考に"線形合同法 - Wikipedia"の値を決めた。

(define my-rand
  (let ((x 1))
    (define (rand-update x)
      (modulo (+ (* x 1103515245) 12345) 2147483647))
    (define (reset new-value)
      (set! x new-value) x)
    (define (generate)
        (set! x (rand-update x)) x))
    (define (dispatch m)
      (cond ((eq? m 'reset) reset)
            ((eq? m 'generate) (generate))
             (error "Unknown"))))

((my-rand 'reset ) 1000)
(my-rand 'generate)

3.1.1 代入と局所状態(続き)




(define (make-monitored func)
  (let ((calls 0))
        (lambda (m)
          (cond ((eq? m 'how-many-calls?) calls)
                ((eq? m 'reset-count) (set! calls 0))
                 (begin (set! calls (+ calls 1))  (func m))


(define (make-acount balance password)
  (define (withdraw amount)
    (if (>= balance amount)
        (begin (set! balance (- balance amount))
        "Insufficient funds"))
  (define (deposit amount)
    (set! balance (+ balance amount))
  (define (dispatch pwd m)
    (if (eq? password pwd)
        (cond ((eq? m 'withdraw) withdraw)
              ((eq? m 'deposit) deposit)
              (else (error "Unknown request")))
        (error "Incorrect password")))


(define (make-acount balance password)
  (define incorrect-types 0)
  (define (withdraw amount)
    (if (>= balance amount)
        (begin (set! balance (- balance amount))
        "Insufficient funds"))
  (define (deposit amount)
    (set! balance (+ balance amount))
  (define (call-the-cops)
    (error "call the cops!"))
  (define (dispatch pwd m)
    (if (eq? password pwd)
          (set! incorrect-types 0)
          (cond ((eq? m 'withdraw) withdraw)
                ((eq? m 'deposit) deposit)
                (else (error "Unknown request"))))
          (if (>= incorrect-types 6)
                (set! incorrect-types (+ incorrect-types 1))
                (error "Incorrect password"))))))

EasterEaster 2012/01/10 06:53 Why does this have to be the ONLY reliable srouce? Oh well, gj!

RayaneRayane 2013/08/07 05:25 That's a smart answer to a tricky qutesion

GauravGaurav 2013/08/09 07:27 Well done <a href="http://jakregph.com">arlitce</a> that. I'll make sure to use it wisely.

EniEni 2013/08/15 13:24 Just the type of ingihst we need to fire up the debate. http://yulljp.com [url=http://hfmrntv.com]hfmrntv[/url] [link=http://wmmuqfw.com]wmmuqfw[/link]

NollieNollie 2016/05/11 00:42 (Escctroniel) This TV has one of the smallest form factors of any of the 40″ flat screen LED TVs so fit in my rather small space 38 1/2″ x 24 1/2″. It has excellent picture and sound. The only reason that I rate it 4* instead of 5* is because it has rather limited inputs and outputs on the back panel (2 HDMI, 1 component video which can alternate as a composite video in) there is no VGA in for a computer, no S-video in, no audio out). It think it is an excellent value. Samsung obviously went with less inputs and outputs and putting their priority in the picture and sound quality of this TV.

AShoorapheloraAShooraphelora 2018/02/24 22:30 Others is capable of a hardon but cannot maintain it during sexual intercourse. Use these circumspectly however, as they may lower glucose levels, which is an unsatisfactory effect in males whose blood glucose levels are properly balanced.

AlbertJuckyAlbertJucky 2018/07/13 21:56 The prostate gland is central to the section of a male's the reproductive system. It secretes fluids that aid in the transportation and activation of sperm. The prostate related is located just in front of the rectum, below the bladder and around the urethra. When there is prostate problem, it will always be really really irritating and inconvenient for that patient as his urinary system is directly affected.

The common prostate health conditions are prostate infection, enlarged prostate and cancer of the prostate.

Prostate infection, also referred to as prostatitis, is among the most common prostate-related condition in men younger than 55 years of age. Infections in the prostate are classified into four types - acute bacterial prostatitis, chronic bacterial prostatitis, chronic abacterial prostatitis and prosttodynia.

Acute bacterial prostatitis will be the least common coming from all types of prostate infection. It is a result of bacteria based in the large intestines or urinary tract. Patients may experience fever, chills, body aches, back pains and urination problems. This condition is treated by making use of antibiotics or non-steroid anti-inflammatory drugs (NSAIDs) to ease the swelling.

Chronic bacterial prostatitis is really a condition connected with a particular defect inside gland and also the persistence presence of bacteria inside the urinary tract. It can be a result of trauma to the urinary tract or by infections originating from other regions of the body. A patient can experience testicular pain, small of the back pains and urination problems. Although it is uncommon, it can be treated by removal in the prostate defect then the use antibiotics and NSAIDs to treat the inflammation.

Non-bacterial prostatitis makes up about approximately 90% of all prostatitis cases; however, researchers have not even to ascertain what causes these conditions. Some researchers believe that chronic non-bacterial prostatitis occur because of unknown infectious agents while other believe that intensive exercise and heavy lifting may cause these infections.

Maintaining a Healthy Prostate

To prevent prostate diseases, an appropriate meals are important. These are some with the actions to maintain your prostate healthy.

1. Drink sufficient water. Proper hydration is important for health and wellness and this will also maintain your urinary track clean.

2. Some studies declare that a few ejaculations a week will help to prevent cancer of prostate.

3. Eat red meat moderately. It has been shown that consuming more than four meals of beef weekly will raise the likelihood of prostate diseases and cancer.

4. Maintain a suitable diet with cereals, vegetable and fruits to be sure sufficient intake of nutrients essential for prostate health.

The most important measure to take to be sure a healthy prostate would be to opt for regular prostate health screening. If you are forty years of age and above, you must go for prostate examination at least per year.


トラックバック - http://sicp.g.hatena.ne.jp/Ehren/20100111