From 8d5fecc23f4e986c74295c58473c6ea8d840d955 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 10 Apr 2021 17:38:46 +0530 Subject: introduce modulus arithmetic to std lisp --- src/grid.rs | 1 - src/lisp/std.lisp | 18 ++++++++++++------ src/main.rs | 7 ++++++- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') 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 { (width * cs) as i32, ((width + 2 * height - i) * cs) as i32 / 2, ); - canvas .draw_line(*start + begin_m.into(), *start + end_m.into()) .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 @@ (define (cdddddr ls) (cdr (cddddr ls))) (define (null? ls) (eq? ls '())) +(define (zero? x) (eq? x 0)) + +(define (remainder x y) + (if (> y x) + x + (remainder (- x y) y))) + +(define (quotient x y) + (/ x y)) + +(define (even? x) (zero? (remainder x 2))) +(define (odd? x) (not (even? x))) (define (length ls) (if (null? ls) @@ -45,9 +57,3 @@ (define (sum ls) (fold 0 + ls)) (define (product ls) (fold 1 * ls)) - -(define (enumerate start stop step) - (if (>= start stop) - '() - (cons start - (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 @@ -#![allow(clippy::upper_case_acronyms, clippy::vec_init_then_push)] +#![allow( + clippy::upper_case_acronyms, + clippy::vec_init_then_push, + clippy::unsound_collection_transmute +)] + mod app; mod bitmap; mod brush; -- cgit v1.2.3