wisp
 
(Arne Babenhauserheide)
2015-11-02: merge say and hashbang

merge say and hashbang

diff --git a/Makefile.am b/Makefile.am
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,13 +24,13 @@ wisp.scm: wisp-guile.w wisp.py
 
 .PHONY: syntaxtests.sh
 syntaxtests.sh : wisp.scm tests/runtests-scheme-preprocessor.sh
-	echo '#!/bin/bash' > @abs_top_builddir@/$@
+	echo '#!/usr/bin/env bash' > @abs_top_builddir@/$@
 	echo @abs_top_srcdir@/tests/runtests-scheme-preprocessor.sh @abs_top_srcdir@ @abs_top_builddir@ >> @abs_top_builddir@/$@
 	chmod +x @abs_top_builddir@/$@
 
 .PHONY: syntaxtestsreader.sh
 syntaxtestsreader.sh : ${wisp} wisp.scm tests/runtests-scheme-reader.sh
-	echo '#!/bin/bash' > @abs_top_builddir@/$@
+	echo '#!/usr/bin/env bash' > @abs_top_builddir@/$@
 	echo @abs_top_srcdir@/tests/runtests-scheme-reader.sh @abs_top_srcdir@ @abs_top_builddir@ >> @abs_top_builddir@/$@
 	chmod +x @abs_top_builddir@/$@
 
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+wisp ():
+- new example: say.w (companion to
+  http://draketo.de/english/wisp/shakespeare )
+- always use /usr/bin/env bash as hashbang for shell scripts.
+
 wisp 0.9.0 (2015-09-24):
 - actually distribute wisp.scm
 - wisp now starts from wisp.scm. To bootstrap a release from Python, 
diff --git a/bootstrap-reader.sh b/bootstrap-reader.sh
--- a/bootstrap-reader.sh
+++ b/bootstrap-reader.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 if [[ x"$1" == x"" ]]; then 
     srcdir=.
diff --git a/bootstrap.sh b/bootstrap.sh
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Bootstrap wisp-guile with wisp.py
 if [[ x"$1" == x"" ]]; then 
diff --git a/examples/fib.w b/examples/running_mean_std.w
copy from examples/fib.w
copy to examples/running_mean_std.w
--- a/examples/fib.w
+++ b/examples/running_mean_std.w
@@ -1,81 +1,34 @@
 #!/home/arne/wisp/wisp-multiline.sh 
 ; !#
 
-;; Fibonacci Functions
+use-modules : srfi srfi-11
 
-define : fibonacci n
-    . "Get Fibonacci Element N in Linear Time"
-    let rek : (i 0) (u 1) (v 1)
-        if : >= i : - n 2
-            . v
-            rek (+ i 1) v (+ u v) ; else
+define : running-stat-fun
+     let
+       : n 0
+         sum 0
+         sum² 0
+       define : mean-std x
+                set! n : + n 1
+                set! sum : + sum x
+                set! sum² : + sum² : expt x 2
+                let*
+                  : mean : / sum n
+                    σ 
+                      - : / sum² n
+                        . mean
+                  values mean σ
+       . mean-std
 
-; display : fib 5
+define statfun : running-stat-fun
 
-;; Try it with curly infix
-
-;; First activate curly infix
-. #!curly-infix 
-
-;; Now define fibonacci with curly infix.
-define : fibonacci n
-    . "Get Fibonacci Element N in Linear Time"
-    let rek : (i 0) (u 1) (v 1)
-        if {i >= {n - 2}}
-            . v
-            rek {i + 1} v {u + v}
-
-display 
-  . {1 + 1}
+write : statfun 5
 newline
-
-;; Due to the compatibility with curly-infix, the following is no longer possible.
-
-;; Try an infix notation with curly brackets - curly infix from readable as simple macro
-;; define-syntax {
-;;     syntax-rules : { }
-;;         : { left infix right } 
-;;           infix left right
-;; 
-;; ; display : { 1 + 2 }
-;; 
-;; ;; Now do the fibonacci again
-;; define : fibcurl n
-;;     . "Get Fibonacci Elements in Linear Time"
-;;     let rek : (i 0) (u 1) (v 1)
-;;         if : { i >= ({ n - 2 }) }
-;;             . v
-;;             rek ({ i + 1 }) v ({ u + v }) ; else
-;; 
-;; ; display : fibcurl 5
-;; 
-;; ;; Do a more complete syntax-rule
-;; 
-;; ;; Try an infix notation with curly brackets - curly infix from readable as simple macro
-;; define-syntax {
-;;     syntax-rules : { }
-;;         : { l in r } 
-;;           in l r
-;;         : { { ll lin lr } in r } 
-;;           in (lin ll lr) r
-;;         : { l in { rl rin rr } } 
-;;           in l (rin rl rr)
-;;         : { { ll lin lr } in { rl rin rr } } 
-;;           in (lin ll lr) (rin rl rr)
-;; 
-;; ;; And a complete infix-fibonacci
-;; define : fibcurl2 n
-;;     . "Get Fibonacci Elements in Linear Time"
-;;     let rek : (i 0) (u 1) (v 1)
-;;         if : { i >= { n - 2 } }
-;;             . v
-;;             rek 
-;;                { i + 1 } 
-;;                . v 
-;;                { u + v }
-;; 
-;; ;; But to be frank: Prefix looks better.
-;; 
-;; display : { { 1 + 2 } * { 2 * 3 } }
-;; ; display : fibcurl2 5
-;; ; TODO: Make the macro recursive, so it can actually cover arbitrary depths of curly braces.
+write : statfun 4
+newline
+let-values 
+    : (mean σ) : statfun 5
+    display mean 
+    display '±
+    display σ
+    newline
diff --git a/wisp-multiline.sh b/wisp-multiline.sh
--- a/wisp-multiline.sh
+++ b/wisp-multiline.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # wisp-multiline.sh --- run multiline wisp code
 
 # Copyright (C) 2013 Arne Babenhauserheide <arne_bab@web.de>
diff --git a/wisp-repl-guile.sh b/wisp-repl-guile.sh
--- a/wisp-repl-guile.sh
+++ b/wisp-repl-guile.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 # if the spec file does not exist yet, run the build chain
 if test ! -f language/wisp/spec.scm; then