Code cleanup
This commit is contained in:
parent
9e8cf71d3b
commit
da71b1bd85
@ -1 +0,0 @@
|
||||
dane@deelite.633:1728402468
|
30
demo.scm
30
demo.scm
@ -23,17 +23,20 @@
|
||||
|
||||
(define (idx->edges i w)
|
||||
(filter-map
|
||||
(lambda (x y)
|
||||
(if (or (negative? (+ (idx->x i w) x))
|
||||
(negative? (+ (idx->y i w) y))
|
||||
(>= (+ (idx->x i w) x) w))
|
||||
#f
|
||||
(xy->idx
|
||||
(+ (idx->x i w) x)
|
||||
(+ (idx->y i w) y)
|
||||
w)))
|
||||
'(+0 -1 -1 +1)
|
||||
'(-1 +0 -1 -1)))
|
||||
(lambda (offset)
|
||||
(let* ([x (idx->x i w)]
|
||||
[y (idx->y i w)]
|
||||
[ox (+ x (car offset))]
|
||||
[oy (+ y (cdr offset))])
|
||||
(and
|
||||
(not (negative? ox))
|
||||
(not (negative? oy))
|
||||
(< ox w)
|
||||
(xy->idx ox oy w))))
|
||||
'(( 0 . -1)
|
||||
(-1 . 0)
|
||||
(-1 . -1)
|
||||
(+1 . -1))))
|
||||
|
||||
(define (generate-web w h)
|
||||
(define (make-node i)
|
||||
@ -42,11 +45,10 @@
|
||||
(+ (* 30 (idx->y i w)) 10))
|
||||
(idx->edges i w)
|
||||
white))
|
||||
(reverse
|
||||
(let loop ([i 0]
|
||||
[lst '()])
|
||||
(if (>= i (* w h))
|
||||
lst
|
||||
(loop (1+ i) (cons (make-node i) lst))))))
|
||||
(reverse lst)
|
||||
(loop (1+ i) (cons (make-node i) lst)))))
|
||||
|
||||
(write-graph-to-file (generate-web 5 5) (cadr (command-line)))
|
||||
|
Loading…
Reference in New Issue
Block a user