Code cleanup
This commit is contained in:
parent
9e8cf71d3b
commit
da71b1bd85
@ -1 +0,0 @@
|
|||||||
dane@deelite.633:1728402468
|
|
36
demo.scm
36
demo.scm
@ -23,17 +23,20 @@
|
|||||||
|
|
||||||
(define (idx->edges i w)
|
(define (idx->edges i w)
|
||||||
(filter-map
|
(filter-map
|
||||||
(lambda (x y)
|
(lambda (offset)
|
||||||
(if (or (negative? (+ (idx->x i w) x))
|
(let* ([x (idx->x i w)]
|
||||||
(negative? (+ (idx->y i w) y))
|
[y (idx->y i w)]
|
||||||
(>= (+ (idx->x i w) x) w))
|
[ox (+ x (car offset))]
|
||||||
#f
|
[oy (+ y (cdr offset))])
|
||||||
(xy->idx
|
(and
|
||||||
(+ (idx->x i w) x)
|
(not (negative? ox))
|
||||||
(+ (idx->y i w) y)
|
(not (negative? oy))
|
||||||
w)))
|
(< ox w)
|
||||||
'(+0 -1 -1 +1)
|
(xy->idx ox oy w))))
|
||||||
'(-1 +0 -1 -1)))
|
'(( 0 . -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)
|
||||||
@ -42,11 +45,10 @@
|
|||||||
(+ (* 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)))
|
||||||
|
Loading…
Reference in New Issue
Block a user