picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit e2638dda1336bd3b033261e15d0cfc002655d8f1
parent f77ff02d57d2909ea5f6471b77f5a50da5db3138
Author: Alexander Burger <abu@software-lab.de>
Date:   Thu,  5 May 2011 13:04:25 +0200

Re-introduced "lib/zahlwort.l", as it is used in "doc/app.html"
Diffstat:
Mdoc/app.html | 37++++++++++++++++++++-----------------
Alib/zahlwort.l | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 17 deletions(-)

diff --git a/doc/app.html b/doc/app.html @@ -32,6 +32,9 @@ All examples were also tested using the w3m text browser. href="ref.html">PicoLisp Reference</a> and the <a href="tut.html">PicoLisp Tutorial</a>. Knowledge of HTML, and a bit of CSS and HTTP is assumed. +<p>The examples assume that PicoLisp was started from a global installation (see +<a href="ref.html#inst">Installation</a>). + <p><ul> <li><a href="#static">Static Pages</a> <ul> @@ -153,12 +156,12 @@ browser to view the effects) <p>Open a second terminal window, and start a PicoLisp application server <pre><code> -$ ./dbg lib/http.l lib/xhtml.l lib/form.l -'server 8080 "project.l"' +$ pil @lib/http.l @lib/xhtml.l @lib/form.l -'server 8080 "project.l"' + </code></pre> <p>No prompt appears. The server just sits, and waits for connections. You can stop it later by hitting <code>Ctrl-C</code> in that terminal, or by executing -'<code>killall picolisp</code>' in some other window. +'<code>killall pil</code>' in some other window. <p>(In the following, we assume that this HTTP server is up and running) @@ -169,10 +172,10 @@ browser. You should see an empty page with a single line of text. <h4><a name="how">How does it work?</a></h4> -<p>The above line loads the debugger ('./dbg', which is equivalent to "./pil -+"), the HTTP server code ("lib/http.l"), the XHTML functions ("lib/xhtml.l") -and the input form framework ("lib/form.l", it will be needed later for <a -href="#forms">interactive forms</a>). +<p>The above line loads the debugger (via the '+' switch), the HTTP server code +("lib/http.l"), the XHTML functions ("lib/xhtml.l") and the input form framework +("lib/form.l", it will be needed later for <a href="#forms">interactive +forms</a>). <p>Then the <code>server</code> function is called with a port number and a default URL. It will listen on that port for incoming HTTP requests in an @@ -292,7 +295,7 @@ resources. function, defined in "lib/http.l" <pre><code> -$ ./pil lib/http.l -'pw 12' -bye +$ pil @lib/http.l -'pw 12' -bye </code></pre> <p>Please execute this command. @@ -460,7 +463,7 @@ $ bin/psh 8080 <p>or start the interpreter stand-alone, with "lib/xhtml.l" loaded <pre><code> -$ ./dbg lib/http.l lib/xhtml.l +$ pil @lib/http.l @lib/xhtml.l + : </code></pre> @@ -774,7 +777,7 @@ your browser and then look at the terminal window where you started the application server, you'll notice a colon, the PicoLisp prompt <pre><code> -$ ./dbg lib/http.l lib/xhtml.l lib/form.l -'server 8080 "project.l"' +$ pil @lib/http.l @lib/xhtml.l @lib/form.l -'server 8080 "project.l"' + : </code></pre> @@ -798,11 +801,11 @@ client. <code>Ctrl-D</code> on an empty line. Otherwise, it will terminate by itself if no other browser requests arrive within a default timeout period of 5 minutes. -<p>To start a (non-debug) production version, the server is commonly started not -as 'dbg' but with a 'p', and with <code>-wait</code> +<p>To start a (non-debug) production version, the server is commonly started +without the '+' flag, and with <code>-wait</code> <pre><code> -$ ./pil lib/http.l lib/xhtml.l lib/form.l -'server 8080 "project.l"' -wait +$ pil @lib/http.l @lib/xhtml.l @lib/form.l -'server 8080 "project.l"' -wait </code></pre> <p>In that way, no command line prompt appears when a client connects. @@ -985,7 +988,7 @@ document via the second button <pre><code> ######################################################################## -(load "lib/ps.l") +(load "@lib/ps.l") (app) @@ -1103,7 +1106,7 @@ href="tut.html#script">Scripting</a> section of the PicoLisp Tutorial. <p>If you like to get a PicoLisp prompt for inspection, start it instead as <pre><code> -$ ./dbg misc/calc.l -main -go +$ pil misc/calc.l -main -go + </code></pre> <p>Then - as before - point your browser to '<code><a @@ -1368,7 +1371,7 @@ of numbers, but expands in the GUI to show also a textual form of each number ######################################################################## (app) -(load "lib/zahlwort.l") +(load "@lib/zahlwort.l") (action (html 0 "Numerals" "lib.css" NIL @@ -2178,13 +2181,13 @@ with a some initial data and two sample reports. <p>As ever, you may start up the application in debugging mode <pre><code> -$ ./dbg app/main.l -main -go +$ pil app/main.l -main -go + </code></pre> <p>or in (non-debug) production mode <pre><code> -$ ./pil app/main.l -main -go -wait +$ pil app/main.l -main -go -wait </code></pre> <p>and go to '<code><a diff --git a/lib/zahlwort.l b/lib/zahlwort.l @@ -0,0 +1,55 @@ +# 26may06abu +# (c) Software Lab. Alexander Burger + +(de zahlwort (N) + (cond + ((not N)) + ((=0 N) "null") + ((lt0 N) (pack "minus " (zahlw (- N)))) + (T (zahlw N)) ) ) + +(de zahlw (N Flg) + (cond + ((=0 N)) + ((= 1 N) (if Flg "ein" "eins")) + ((= 2 N) "zwei") + ((= 3 N) "drei") + ((= 4 N) "vier") + ((= 5 N) "fünf") + ((= 6 N) "sechs") + ((= 7 N) "sieben") + ((= 8 N) "acht") + ((= 9 N) "neun") + ((= 10 N) "zehn") + ((= 11 N) "elf") + ((= 12 N) "zwölf") + ((= 17 N) "siebzehn") + ((> 20 N) + (pack (zahlw (% N 10) T) "zehn") ) + ((> 100 N) + (pack + (unless (=0 (% N 10)) + (pack (zahlw (% N 10) T) "und") ) + (get + (quote + "zehn" "zwanzig" "dreissig" "vierzig" "fünfzig" + "sechzig" "siebzig" "achtzig" "neunzig" ) + (/ N 10) ) ) ) + ((> 1000 N) + (pack + (zahlw (/ N 100) T) + "hundert" + (zahlw (% N 100)) ) ) + ((> 1000000 N) + (pack + (zahlw (/ N 1000) T) + "tausend" + (zahlw (% N 1000)) ) ) + ((> 2000000 N) + (pack "einemillion" (zahlw (% N 1000000))) ) + ((> 1000000000000 N) + (pack + (zahlw (/ N 1000000) T) + "millionen" + (zahlw (% N 1000000)) ) ) + (T "RIESIG") ) )