diff options
-rw-r--r-- | chicken-5.org | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/chicken-5.org b/chicken-5.org index 95800a3..86dce1a 100644 --- a/chicken-5.org +++ b/chicken-5.org @@ -71,10 +71,10 @@ (set! a b) (set! b x))))) - ;; Does the right thing, i.e. print 2: + ;; Does the right thing, i.e. print 1: (let ((x 1) (y 2)) (swap! x y) - (display x)) + (display y)) #+END_SRC * Scheme superpowers: closures @@ -160,12 +160,12 @@ (foreign-declare "#include <math.h>") - (define twice-exp + (define sin-pi (foreign-lambda* double ((double x)) - "double result = exp(x);" - "C_return(result * 2.0);")) + "double val = x * M_PI;" + "C_return(sin(val));")) - (display (twice-exp 5)) ;; 296.826318205153 + (display (sin-pi 0.5)) ;; prints 1.0 #+END_SRC * CHICKEN: Community |