aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-10 13:08:46 +0100
committerAkshay <[email protected]>2021-04-10 13:08:46 +0100
commit8d5fecc23f4e986c74295c58473c6ea8d840d955 (patch)
treef9bea6b4bb21b74ee18bb1b679ec0ee959f9b716 /src
parenteab6c543d19f7546f1151cca32663035006af702 (diff)
introduce modulus arithmetic to std lisp
Diffstat (limited to 'src')
-rw-r--r--src/grid.rs1
-rw-r--r--src/lisp/std.lisp18
-rw-r--r--src/main.rs7
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
2mod app; 7mod app;
3mod bitmap; 8mod bitmap;
4mod brush; 9mod brush;