diff options
Diffstat (limited to 'algebraic-structures.group.scm')
-rw-r--r-- | algebraic-structures.group.scm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/algebraic-structures.group.scm b/algebraic-structures.group.scm new file mode 100644 index 0000000..6e38eaf --- /dev/null +++ b/algebraic-structures.group.scm @@ -0,0 +1,16 @@ +(functor ((algebraic-structures group) (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))))))) |