Skip to content

Instantly share code, notes, and snippets.

@osoleve
Created March 18, 2011 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osoleve/875629 to your computer and use it in GitHub Desktop.
Save osoleve/875629 to your computer and use it in GitHub Desktop.
Simple function (and helper function) to calculate Sine using Scheme
(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