Compare commits

..

No commits in common. "da71b1bd85eef8978ef58c5ab17808b0c6481552" and "bc61ef7d8f1b4caa562734bb129728f2b2372c39" have entirely different histories.

View File

@ -23,20 +23,17 @@
(define (idx->edges i w) (define (idx->edges i w)
(filter-map (filter-map
(lambda (offset) (lambda (x y)
(let* ([x (idx->x i w)] (if (or (negative? (+ (idx->x i w) x))
[y (idx->y i w)] (negative? (+ (idx->y i w) y))
[ox (+ x (car offset))] (>= (+ (idx->x i w) x) w))
[oy (+ y (cdr offset))]) #f
(and (xy->idx
(not (negative? ox)) (+ (idx->x i w) x)
(not (negative? oy)) (+ (idx->y i w) y)
(< ox w) w)))
(xy->idx ox oy w)))) '(+0 -1 -1 +1)
'(( 0 . -1) '(-1 +0 -1 -1)))
(-1 . 0)
(-1 . -1)
(+1 . -1))))
(define (generate-web w h) (define (generate-web w h)
(define (make-node i) (define (make-node i)
@ -45,10 +42,11 @@
(+ (* 30 (idx->y i w)) 10)) (+ (* 30 (idx->y i w)) 10))
(idx->edges i w) (idx->edges i w)
white)) white))
(reverse
(let loop ([i 0] (let loop ([i 0]
[lst '()]) [lst '()])
(if (>= i (* w h)) (if (>= i (* w h))
(reverse lst) lst
(loop (1+ i) (cons (make-node i) lst))))) (loop (1+ i) (cons (make-node i) lst))))))
(write-graph-to-file (generate-web 5 5) (cadr (command-line))) (write-graph-to-file (generate-web 5 5) (cadr (command-line)))