diff options
author | Akshay <[email protected]> | 2021-04-10 13:08:46 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-04-10 13:08:46 +0100 |
commit | 8d5fecc23f4e986c74295c58473c6ea8d840d955 (patch) | |
tree | f9bea6b4bb21b74ee18bb1b679ec0ee959f9b716 | |
parent | eab6c543d19f7546f1151cca32663035006af702 (diff) |
introduce modulus arithmetic to std lisp
-rw-r--r-- | src/grid.rs | 1 | ||||
-rw-r--r-- | src/lisp/std.lisp | 18 | ||||
-rw-r--r-- | src/main.rs | 7 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/grid.rs b/src/grid.rs index ed1dd83..9baf364 100644 --- a/src/grid.rs +++ b/src/grid.rs | |||
@@ -93,7 +93,6 @@ impl Grid { | |||
93 | (width * cs) as i32, | 93 | (width * cs) as i32, |
94 | ((width + 2 * height - i) * cs) as i32 / 2, | 94 | ((width + 2 * height - i) * cs) as i32 / 2, |
95 | ); | 95 | ); |
96 | |||
97 | canvas | 96 | canvas |
98 | .draw_line(*start + begin_m.into(), *start + end_m.into()) | 97 | .draw_line(*start + begin_m.into(), *start + end_m.into()) |
99 | .unwrap(); | 98 | .unwrap(); |
diff --git a/src/lisp/std.lisp b/src/lisp/std.lisp index 2a042a0..6c5beed 100644 --- a/src/lisp/std.lisp +++ b/src/lisp/std.lisp | |||
@@ -9,6 +9,18 @@ | |||
9 | (define (cdddddr ls) (cdr (cddddr ls))) | 9 | (define (cdddddr ls) (cdr (cddddr ls))) |
10 | 10 | ||
11 | (define (null? ls) (eq? ls '())) | 11 | (define (null? ls) (eq? ls '())) |
12 | (define (zero? x) (eq? x 0)) | ||
13 | |||
14 | (define (remainder x y) | ||
15 | (if (> y x) | ||
16 | x | ||
17 | (remainder (- x y) y))) | ||
18 | |||
19 | (define (quotient x y) | ||
20 | (/ x y)) | ||
21 | |||
22 | (define (even? x) (zero? (remainder x 2))) | ||
23 | (define (odd? x) (not (even? x))) | ||
12 | 24 | ||
13 | (define (length ls) | 25 | (define (length ls) |
14 | (if (null? ls) | 26 | (if (null? ls) |
@@ -45,9 +57,3 @@ | |||
45 | 57 | ||
46 | (define (sum ls) (fold 0 + ls)) | 58 | (define (sum ls) (fold 0 + ls)) |
47 | (define (product ls) (fold 1 * ls)) | 59 | (define (product ls) (fold 1 * ls)) |
48 | |||
49 | (define (enumerate start stop step) | ||
50 | (if (>= start stop) | ||
51 | '() | ||
52 | (cons start | ||
53 | (enumerate (+ start step) stop step)))) | ||
diff --git a/src/main.rs b/src/main.rs index 220956a..d6f0204 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -1,4 +1,9 @@ | |||
1 | #![allow(clippy::upper_case_acronyms, clippy::vec_init_then_push)] | 1 | #![allow( |
2 | clippy::upper_case_acronyms, | ||
3 | clippy::vec_init_then_push, | ||
4 | clippy::unsound_collection_transmute | ||
5 | )] | ||
6 | |||
2 | mod app; | 7 | mod app; |
3 | mod bitmap; | 8 | mod bitmap; |
4 | mod brush; | 9 | mod brush; |