(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 (list (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))) (list ;; 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 nodedist nodedep) (letrec ( ;; nodeinit -> to init all node values on -1 (nodeinit (lambda (ndlst) (if (null? ndlst) '() (begin (define (caar ndlst) -1) (nodeinit (cdr ndlst)))))) ;; nlist -> list of nodes (nlist (crnode nodedist)) ;; crnode -> node builder (crnode (lambda (x) (if (null? x) '() (cons (caar x) (crnode (cdr x)))))) ;; crndtaken -> find if nodes have already ben set builder (crndtaken (lambda (lst) (and (not (= (eval (caar lst)) -1)) (crndtaken (cdr lst))))) ;; nodenottaken? -> find if there are unset nodes (nodenottaken? (crndtaken nodedist)) (compute (lambda (ndlst) (if (not (null? ndlst)) (begin ( (begin (nodeinit nodedist) (while (nodenottaken?) (compute nodelist)))