From da71b1bd85eef8978ef58c5ab17808b0c6481552 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Fri, 11 Oct 2024 17:57:45 -0500 Subject: [PATCH] Code cleanup --- .#demo.scm | 1 - demo.scm | 36 +++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) delete mode 120000 .#demo.scm diff --git a/.#demo.scm b/.#demo.scm deleted file mode 120000 index d382f6b..0000000 --- a/.#demo.scm +++ /dev/null @@ -1 +0,0 @@ -dane@deelite.633:1728402468 \ No newline at end of file diff --git a/demo.scm b/demo.scm index 59fa2ec..d96ac9b 100644 --- a/demo.scm +++ b/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)))))) + (let loop ([i 0] + [lst '()]) + (if (>= i (* w h)) + (reverse lst) + (loop (1+ i) (cons (make-node i) lst))))) (write-graph-to-file (generate-web 5 5) (cadr (command-line)))