From a1b1d10ad5fc505f8b83ac6976e5eb68b87427ff Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Wed, 12 Jun 2024 02:43:00 +0900 Subject: Add group modules --- algebraic-structures.group.make.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 algebraic-structures.group.make.scm (limited to 'algebraic-structures.group.make.scm') diff --git a/algebraic-structures.group.make.scm b/algebraic-structures.group.make.scm new file mode 100644 index 0000000..7568ac9 --- /dev/null +++ b/algebraic-structures.group.make.scm @@ -0,0 +1,16 @@ +(functor ((algebraic-structures group make) (M (<> unit inv))) + (<> unit inv pow) + (import M + scheme + (chicken base)) + + (define (pow x n) + (assert (exact-integer? n)) + (if (negative? n) + (pow (inv x) (- n)) + (let loop ((i n) + (acc unit)) + (if (= i 0) + acc + (loop (sub1 i) + (<> acc x))))))) -- cgit v1.2.3