Created
March 18, 2011 04:44
-
-
Save osoleve/875629 to your computer and use it in GitHub Desktop.
Simple function (and helper function) to calculate Sine using Scheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (factorial n) | |
(if (= n 0) | |
1 | |
(* n (factorial (- n 1))))) | |
(define (sine x . n) | |
(cond ((not (null? n)) | |
(cond ((< 13 (car n)) | |
0) | |
(else (- (/ (expt x (car n)) (factorial (car n))) | |
(sine x (+ 2 (car n))))))) | |
(else (- x (sine x 3))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment