RosettaCodeData/Task/Call-a-function-in-a-shared-library/Racket/call-a-function-in-a-shared-library.rkt
Ingy döt Net 764da6cbbb CDE
2013-04-10 16:57:12 -07:00

6 lines
306 B
Racket

#lang racket
(require ffi/unsafe)
(define libm (ffi-lib "libm")) ; get a handle for the C math library
; look up sqrt in the math library. if we can't find it, return the builtin sqrt
(define extern-sqrt (get-ffi-obj 'sqrt libm (_fun _double -> _double)
(lambda () sqrt)))