<?php include('HEADER.php'); ?>

<h1>Scheme Programming Notes</h1>

<h2>Chicken</h2>

<p>There are a number of good implementations of Scheme. I'm using <a href="http://www.call-cc.org/">Chicken Scheme</a>. It has a <a href="http://wiki.call-cc.org/man/4/The%20User%27s%20Manual">manual</a>.</p>

<p>Invoke the REPL with <code>csi</code>. Within the REPL, you can load a file like <code>(load "test.scm")</code>.</p>

<p>Run a script like <code>csi -s test.scm</code>.</p>

<p>Also see <code>csi -help</code>.</p>

<p>Chicken can compile executables like <code>csc -o test test.scm</code>.</p>

<p>Chicken modules are called <em>eggs</em>. Install an egg like <code>$ chicken-install egg-name</code>. The module can then be used with <code>(use egg-name)</code>.</p>

<h2>Hello, world!</h2>

<pre style="prettyprint">; A comment.
(define (hello)
  (display "Hello, world!")
  (newline))

(hello)</pre>

<h2>Types</h2>

<pre>(boolean? #t)    ; True
(boolean? "Hello, World!    ; False
(not #f)    ; True
(not #t)    ; False
(not "Hello, World")    ; False

(number? 42)    ; True
(number? #t)    ; False
(integer? 10/3)    ; False

(eqv? 42 42)    ; True
(eqv? 42 "Hello, world!")   ; False

(= 42 42)    ; True.
(= 42 #f)    ; Error. Unlike eqv?, = is a numeric-only operator.

(+ 2 2)    ; 4

(max 1 2 3 4)    ; 4
(mim 1 2 3 4)    ; 1

(abs -2)    ; 2</pre>

<h2>Symbols</h2>

<pre>(quote abc)    ; abc
'abc    ; Shorthand for (quote abc)

(define x 3)    ; Define variable
(set! x 9)    ; Set new value</pre>

<h2>String</h2>

<pre>(define z "Hello")
(string-append z ", world!")    ; "Hello, world!"
(string? z)    ; #t</pre>

<h2>Links</h2>

<ul>
<li><a href="http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html">Teach Yourself Scheme in Fixnum Days</a></li>
<li><a href="http://www.scheme.com/tspl4/">The Scheme Programming Language</a></li>
<li><a href="http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-1.html">How to Design Programs </a></li>
<li><a href=""></a></li>
</ul>

<?php include('../FOOTER.php'); ?>
