learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-6.scm (461B)


      1 (define-library (sicp solutions chapter-3 exercise-6)
      2   (import (scheme base))
      3   (import (only (guile)
      4                 *random-state*
      5                 random:uniform
      6                 seed->random-state
      7                 ))
      8   (export rand)
      9 
     10   (begin
     11     (define (rand command . value)
     12       (cond
     13        ((eq? 'generate command)
     14         (random:uniform))
     15        ((eq? 'reset command)
     16         (set! *random-state*
     17               (seed->random-state (car value))))))))