(use srfi-1) (use srfi-27) (define-syntax while (syntax-rules () ((while condition things ... ) (do () ((not condition)) things ...)))) ;; (define x 0) ;; (while (< x 10) (set! x (+ x 1)) (display x)) (define obra (graph ;; nodes and distributions `((T1 ,(uniform 32 48)) (T2 ,(uniform 40 60)) (T3 ,(uniform 15 25)) (T4 ,(uniform 10 15)) (T5 ,(uniform 10 15)) (T6 ,(uniform 6 10)) (T7 ,(uniform 18 24)) (T8 ,(uniform 4 8))) ;; dependencies '((T2 . T1) (T3 . T1) (T3 . T2) (T4 . T2) (T5 . T2) (T5 . T3) (T6 . T2) (T7 . T2) (T7 . T4) (T7 . T5) (T8 . T4) (T8 . T5) (T8 . T6) (T8 . T7)))) (define (uniform min max) (+ min (* (- max min) (random-real)))) (define (graph nodes-with-distributions node-dependencies) ;; crnd-taken -> find if nodes have already ben set builder (define (crnd-taken lst) (every (lambda (node) (not (= (eval (car node)) -1))) lst)) ;; node-not-taken? -> find if there are unset nodes (define (node-not-taken?) (crnd-taken nodes-with-distributions)) (define (compute ndlst) (if (not (null? ndlst)) (begin (...)) ...)) ;; nlist -> list of nodes (define nlist (map car node-with-distributions)) ;; init all node values on -1 (for-each (lambda (node) ;; hm, probably not what you want (set-car! node -1)) nodes-with-distributions) (while (node-not-taken?) (compute nodes-with-distributions)))