In KSM-Scheme, whitespace characters are spaces, tabs, and newlines. Whitespace is used for improved readability and is necessary to separate tokens from each other but is otherwise insignificant.
A semicolon (;) indicates the start of a comment. The comment
continues to the end of the line on which the semicolon
appears. Comments are invisible to Scheme, but the end of the line is
visible as whitespace. This prevents a comment from appearing in the
middle of an identifier or number.
;;; The FACT procedure computes the factorial
;;; of a non-negative integer.
(define fact
(lambda (n)
(if (= n 0)
1 ;Base case: return 1
(* n (fact (- n 1))))))
Two characters #! (character # followed by !) also
starts a comment. The comment continues to the end of the line on which
#! appears. This enables a Scheme program executed as an
interpreter file, like this:
#!/usr/local/bin/ksm -f (display "Hello, world!") (newline)
Go to the first, previous, next, last section, table of contents.