Skip to content

Instantly share code, notes, and snippets.

@pete
Created March 26, 2009 22:40
Show Gist options
  • Save pete/86410 to your computer and use it in GitHub Desktop.
Save pete/86410 to your computer and use it in GitHub Desktop.
; Roboto-FFI!
(= LibM
(ffi-bind '("m") '("math.h")
(pi (ffi-const 'double 'M_PI))
(sin (ffi-func 'double 'sin '(double)))))
(LibM '(do
(= epsilon 0.000001)
(def within-epsilon (a b)
(< (- epsilon) (- a b) epsilon))))
(puts "(FFI!)")
(test "sin(0.5π) is 1 (libc M_PI precision aside...)"
(LibM '(within-epsilon 1 (sin (/ pi 2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment