diff options
author | Peter Bex <peter@more-magic.net> | 2019-05-06 21:23:23 +0200 |
---|---|---|
committer | Peter Bex <peter@more-magic.net> | 2019-05-06 21:24:49 +0200 |
commit | 68627f2edfc9ef5594e225ad504d484ea46c7b4f (patch) | |
tree | f55566c0395c41b66f3afeb1e4ee4a34398260ad | |
parent | fd32b90f756077fb83e2f856be64c4018e17f65a (diff) | |
download | t-dose-chicken-5-68627f2edfc9ef5594e225ad504d484ea46c7b4f.tar.gz |
Improve examples a bit
-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 |