aboutsummaryrefslogtreecommitdiff
path: root/algebraic-structures.group.make.scm
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2024-06-12 02:43:00 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2024-06-12 02:43:00 +0900
commita1b1d10ad5fc505f8b83ac6976e5eb68b87427ff (patch)
treefc178e36cbd7bbb45f9043062a74e4e6cab1ed94 /algebraic-structures.group.make.scm
parent7e9013fc2ae5d82dfc0b152089c94d6c78e245b3 (diff)
Add group modules
Diffstat (limited to 'algebraic-structures.group.make.scm')
-rw-r--r--algebraic-structures.group.make.scm16
1 files changed, 16 insertions, 0 deletions
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)))))))