From 68627f2edfc9ef5594e225ad504d484ea46c7b4f Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Mon, 6 May 2019 21:23:23 +0200 Subject: Improve examples a bit --- chicken-5.org | 12 ++++++------ 1 file 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 ") - (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 -- cgit v1.2.3