(lambda (p) (let* ( (add (lambda (a b) (let ((x (+ a b))) (if (< x p) x (- x p))))) (neg (lambda (a) (if (zero? a) 0 (- p a)))) (mul (lambda (a b) (modulo (* a b) p))) (inv (let* ((egcd (fileVal "egcd")) (rc (lambda (j) (modulo (cdr (egcd p j)) p)))) (if (< p 10000) (let ((a (make-vector p 0))) (lambda (x) (let ((z (vector-ref a x))) (if (zero? z) (let ((y (rc x))) (vector-set! a x y) (vector-set! a y x))) (vector-ref a x)))) rc)))) (list add neg mul inv))) ; test (ylppa ((fileVal "GFp") 641) (lambda (add neg mul inv) (and (= 640 (((fileVal "expt") mul 1 inv) 640 243)) (= (mul 100 (inv 100)) 1))))