CDATA
, #PCDATA
, and ANY
get-url
and web agents
QUERY_STRING
and POST
messages
QUERY_STRING
tiff-prober
symbol?
with syntax-rules
lambda
as a
library syntax
set!
quote
-- as a macro
setf
-- a polymorphic, generic setter -- as a simple Scheme macro
call/cc
shift
/reset
made aware of the dynamic
environment.
control
,
shift0
, control0
and others
shift
/reset
control0
through
control
to
shift
F
operators
call/cc
and Y
assert
macro with informative reports on failure
define-opt
:
A concise definition form with optional arguments and default values
lookup-def
: Look up a value in alists of various formats
and handle the look-up failure
OS:within-critical-section
, as well as reading and writing through TCP, uni- and bidirectional pipes.
UNIX
(POSIX)
directory and getting file status information
AND-LET*
: an AND
with local bindings,
a guarded LET*
special form (SRFI-2)
string-split
, substring?
, list-intersperse
and other helpful string and list manipulation utilities
write-substring
and port-copy
with a highly efficient fast path code.
pi
, log2
, compiler-option-dependent data. In addition, the #,
form can be used for conditional compilation, in spirit of SRFI-0 and feature expressions of Common Lisp.
call/cc
fold
combinator
eval
-uating open code
bottom
terms
IF
as a pure function
#include
: an article about C
, but with Scheme
undertones
An ordered dictionary data structure, based on randomized search trees (treaps) by Seidel and Aragon. Compared to red-black trees, treap is simpler and more elegant, and can get by without sentinels. | |
procedure: make-treap KEY-COMPARE-PROC |
|
creates a treap object. Here The treap object responds to a variety of query and update messages, including efficient methods for finding the minimum and maximum keys and their associated values, as well as traversing of a treap in an ascending or descending order of keys.
Looking up an arbitrary or the min/max keys, and deleting the min/max keys require no more key comparisons than the depth of the treap, which is All the treap object operations are thoroughly documented in the source code. Martin Gasbichler has kindly ported treaps to Scheme48 and included in the Scheme Untergrund Library. | |
Version | |
---|---|
The current version is 1.2, Sep 2, 1997. | |
References | |
treap.scm [24K] vtreap.scm [7K] Treaps in the Scheme Untergrund Library A USENET article announcing release of treaps [plain text file] A USENET article touting treaps as an efficient implementation for priority queues [plain text file] R. Seidel and C. R. Aragon, Randomized Search Trees, Algorithmica, 16(4/5):464-497, 1996. Stefan Nilsson, Treaps in Java, Dr.Dobb's Journal, July 1997, p.40-44.
| |
From other archives | |
|
One (in case of matching) or both (for unification) trees may
contain variables, whose names begin with an underscore. A variable
whose name is a lone underscore is an anonymous, wildcard variable,
like the one in Prolog.
The result of matching or unification is a set of bindings of
pattern variables to terms. We call this set 'environment' (env). In
the term re-writing literature such a set of bindings is usually
called 'substitutions'. Procedures | |
procedure: match-tree TREE1 TREE2 ENV -> ENV |
|
A non-linear match of two ordered trees. TREE1 may
contain variables, even several occurrences of the same variable. All
these occurrences must match the same term. A variable match is
entered into the environment. A variable _ is an
exception: its match
is never entered into the environment. The function returns the
resulting environment or #f if the match fails.
| |
procedure: unify-trees TREE1 TREE2 ENV -> ENV |
|
A unification of two ordered trees, both of which may contain
variables (including several occurrences of the same variable). The
unifier is capable of finding cyclic substitutions. Often
unify-trees should be followed by
normalize-subst below.
Splitting the unification into two phases is for efficiency reasons:
If we are interested only in the fact if two terms unify, we do not
need to apply normalize-subst .
| |
procedure: normalize-subst ENVI ACCEPT-CYCLIC? -> (ENVO | #f) |
|
ENVI is a set of bindings as returned by
unify-trees . ENVO is, informally speaking, a
transitive closure of ENVI . If ENVI is
acyclic, then ENVO is the fixpoint of composing
ENVI with itself. If the flag ACCEPT-CYCLIC?
is #f and ENVI turns out to be cyclic, we
return #f . If ACCEPT-CYCLIC? is
#t , we always return the environment, which may contain
recursive and mutually recursive bindings. Setting the flag
ACCEPT-CYCLIC? to #f essentially enables
the occurs-check. Many
Prolog systems omit the occurs-check altogether for
performance reasons: see SICTus
Prolog Manual, p. 50. The manual states that unifying without the
occurs-check is wrong but practical. In our algorithm however, cyclic
and acyclic unifications have exactly the same time and space complexities. The
occurs-check (passing #f as ACCEPT-CYCLIC? )
does not impose any penalty at all.
The source code contains extensive explanations and tests. The test cases
specifically include pathological terms. The latter
cause the conventional, textbook unification algorithm (recursive
descent with the composition of substitutions, due to Robinson (1965))
to exponentially blow-up in time and in space. Our algorithm remains
linear in space. Because we store bindings in an associative list and
use
It seems that our algorithm is somewhat similar to Gerard Huet's
linear unification algorithm. The latter has quite different
intuition: re-writing of equations into a canonical form. In a sense,
our | |
Version | |
---|---|
The current version is 3.0, Jul 4, 2003. | |
References | |
tree-unif.scm [30K] An applicative-order
term rewriting system for code generation, and its termination
analysis: generating efficient median filters tree-unif.txt
|
A Scheme-database interface via scripting of a SQL user front-end. A major procedure:
There are a few minor variants of the above procedure, optimized
for common particular cases: | |
Version | |
---|---|
The current version is 2.7, May 10, 2003. | |
References | |
db-util1.scm [23K] db-util.scm [12K] vdb-util.scm [7K] vdbaccess.scm [4K] Platform-independent higher-order
distributed SQL database interface: The most primitive and nearly universal database interface Towards the
best collection traversal interface |
A Scheme-database interface via scripting of a SQL user front-end. The poorest-man solution is demonstrated with Illustra RDBMS as an example. A richer-man interface scripts an SQL interpreter from within Scheme, in a genuine client-server way. It is shown off using Informix 7.2 On-Line. | |
Version | |
---|---|
The current version is 1.2, Oct 31, 1997. | |
References | |
prim-db-intf.scm [3K] A USENET article explaining the technique [plain text file] Another USENET article that explains how to make scripting work across the network [plain text file] | |
From other archives | |
|
The present code implements a classless, delegation-based OO system, similar to those of Self or Javascript. This is a full-fledged OO system with encapsulation, object identity, inheritance and polymorphism. It is also a purely functional system: there is not a single assignment or other mutation in the code below.
Objects' identity is decided by an | |
Version | |
---|---|
The current version is 1.2, February 29, 2000. | |
References | |
pure-oo-system.scm [6K] A USENET article [plain text file] | |
From other archives | |
|
This calculator implements a normal-order evaluator for the untyped lambda-calculus with shortcuts. Shortcuts are distinguished constants that represent terms. An association between a shortcut symbol and a term must be declared before any term that contains the shortcut could be evaluated. The declaration of a shortcut does not cause the corresponding term to be evaluated. Therefore shortcut's term may contain other shortcuts -- or even yet to be defined ones. Shortcuts make programming in lambda-calculus remarkably more convenient. Besides terms to reduce, this lambda-calculator accepts a set of commands, which add even more convenience. Commands define new shortcuts, activate tracing of all reductions, compare terms modulo alpha-conversion, print all defined shortcuts and evaluation flags, etc. Terms to evaluate and commands are entered at a read-eval-print-loop (REPL) "prompt" -- or "included" from a file by a special command. ExamplesFirst we define a few shortcuts: (X Define %c0 (L f (L x x))) ; Church numeral 0 (X Define %succ (L c (L f (L x (f (c f x)))))) ; Successor (X Define* %c1 (%succ %c0)) (X Define* %c2 (%succ %c1)) (X Define %add (L c (L d (L f (L x (c f (d f x))))))) ; Add two numerals (X Define %mul (L c (L d (L f (c (d f)))))) ; Multiplication (%add %c1 %c2) REPL reduces the term and prints the answer: (L f (L x (f (f (f x))))) .
(X equal? (%succ %c0) %c1) (X equal?* (%succ %c0) %c1)The REPL executes the above commands and prints the answer: #f and #t , correspondingly. The second
command reduces the terms before comparing them.
This all looks suspiciously like Scheme. However, try the following
two terms:
The title comments to the source code of the calculator explain the
differences between a call-by-value evaluator such as Scheme, an
applicative-order lambda-calculator, a normal-order evaluator such as
Scheme's macro-expander, and the present normal-order lambda-calculator.
| |
Platforms | |
---|---|
The package is tested on Gambit-C 3.0, SCM 5d2 and Bigloo 2.2b | |
Version | |
The current version is 1.1, March 30, 2001. | |
References | |
lambda-calc.scm [28K] lambda-arithm-basic.scm [3K] Lambda Calculus and Lambda Calculators |
Read-time application is an extensible external representation of Scheme values. It is similar to Smalltalk's object serialization and Examples: Alternative printed representations for standard Scheme datatypes and other values (define-reader-ctor '+ +) (with-input-from-string "#,(+ 1 2)" read) ==> 3Readable representations for structures (records) (define-reader-ctor 'my-vector (lambda x (apply vector (cons 'my-vector-tag x)))) (with-input-from-string "#,(my-vector #,(my-vector #,(+ 9 -4)))" read) ==> '#(my-vector-tag #(my-vector-tag 5))Representing uniform vectors (per SRFI-4) in the #, notation
(define-reader-ctor 'f32 f32vector) (with-input-from-string "#,(f32 1.0 2.0 3.0)" read) ==> a uniform f32 vector with three elementsExternal representations for 'complex' datatypes, eg, ports (define-reader-ctor 'file open-input-file) (with-input-from-string "#,(file \"/tmp/a\")" (lambda () (read-char (read)))will return the first character of the file " /tmp/a ".
printing cond-expanded code from SRFI-0, example 1... #,(cond-expand ((and srfi-1 srfi-10) (write 1)) ((or srfi-1 srfi-10) (write 2)) (else)) when features (srfi-1) are defined: (begin (write 2)) when features (srfi-10) are defined: (begin (write 2)) when features (srfi-1 srfi-10) are defined: (begin (write 1)) when features (srfi-2) are defined: (begin)Emulating #+ and #- of Common Lisp, specifically, examples of feature expressions from Section 24.1.2.1.1 of
ANSI Common Lisp standard, X3.226.
interpreting a string: (cons #,(cond-expand (lispm "Spice") (spice "foo") ((not (or lispm spice)) 7)) 'x) when features (spice perq) are defined: ("foo" . x) when features (lispm) are defined: ("Spice" . x) when features (srfi-10) are defined: (7 . x) The read-time application proposal has been submitted as a SRFI " | |
Version | |
---|---|
The current version is 1.1, Jul 4, 1999. | |
References | |
read-apply.scm [10K] vread-apply.scm [4K] A USENET article [plain text file] cond-expand.scm [3K] vcond-expand.scm [3K] A USENET article [plain text file] | |
From other archives | |
|
oleg-at-okmij.org