Download The Reasoned Schemer PDF

TitleThe Reasoned Schemer
File Size3.1 MB
Total Pages177
Table of Contents
                            Front Cover
Copyright
Contents
Preface
1. Playthings
2. Teaching Old Toys New Tricks
3. Seeing Old Friends in New Ways
4. Members Only
5. Double Your Fun
6. The Fun Never Ends...
7. A Bit Too Much
8. Just a Bit More
9. Under the Hood
10. Thin Ice
Connecting the Wires
Welcome to the Club
Index
                        
Document Text Contents
Page 2

The Reasoned Schemer

Page 88

What is the value of †

(run1 (q)
(condi

((! #f q) always o)
(else (! #t q)))

(! #t q))


condi is written condi and is pronounced “con-deye”.

19
((#t)),

because after the first failure, instead of
staying on the first line we try the second
condi line.

What happens if we try for more values?

(run2 (q)
(condi

((! #f q) always o)
(else (! #t q)))

(! #t q))

20
It has no value,

since the second condi line is out of values.

So does this give more values?

(run5 (q)
(condi

((! #f q) always o)
(else (any o (! #t q))))

(! #t q))

21
Yes, it yields as many as are requested,

((#t #t #t #t #t)).
always o succeeds five times, but
contributes none of the five values, since
then #f would be in the list.

Compare condi to conde.
22

condi looks and feels like conde. condi
does not, however, wait until all the
successful goals on a line are exhausted
before it tries the next line.

Are there other differences?
23

Yes. A condi line that has additional values
is not forgotten. That is why there is no
value in frame 20.

80 Chapter 6

Page 89

The Law of condi
condi behaves like conde, except
that its values are interleaved.

What is the value of

(run5 (r)
(condi

((teacup o† r) #s)
((! #f r) #s)
(else #u)))


See 1:56.

24
((tea #f cup)).

Let’s be sure that we understand the
di!erence between conde and condi.
What is the value of

(run5 (q)
(condi

((! #f q) always o)
((! #t q) always o)
(else #u))

(! #t q))

25
((#t #t #t #t #t)).

And if we replace condi by conde, do we get
the same value?

26
No,

then the expression has no value.

Why does

(run5 (q)
(conde

((! #f q) always o)
((! #t q) always o)
(else #u))

(! #t q))
have no value?

27
It has no value,

because the first conde line succeeds, but
the outer (! #t q) fails. This causes the
first conde line to succeed again, etc.

The Fun Never Ends . . . 81

Page 176

memo, 48
simplified definition, 50

member?, 36
member o, 36
memberrev o, 44
Mercury, 148

soft-cut operator, 148
Moggi, Eugenio, 159
monadic operation, 159
mplus, 159, 161
mplusi (mplusi), 159, 161
mzero, 159, 160

n-representative, 99
Nagel, Ernest, 163
Naish, Lee, 148
never o, 77
Newman, James R., 163
non-overlapping property, 93
notational conventions, ix
not-pasta o, 147
no value (for an expression), 29
null?, 21
null o, 22
number!string, 139

occurs
!

(occurs-check), 140
odd-"o (odd-*o), 112
once o, 149, 151

pair o, 24
pmember o, 40

with additional conde line, 41
testing that cdr is not the empty list, 42
swapping first and second conde lines, 43

pos o, 97
programming languages

Haskell, x
Mercury, 148

soft-cut operator, 148
Prolog, ix

cut operator, 148
anonymous variable, 131

Scheme, ix
macros, ix

project, 138
Prolog, ix

cut operator, 148
anonymous variable, 131

proper list, 27
punctuation, ix

question (of a cond line), 10

refresh (a variable), 11
reified

name, 8
variable, 8

reify, 140
reify-name, 7, 17, 139
reify-s, 139
relational programming, ix
relations

partitioning into unnamed functions, x
rember, 51
rember o, 51

redefined using cons o, 52
repeated-mul o (help function for logo), 127
reverse-list, 45
rhs, 132
Robinson, John Alan, 132
run, 12, 159, 160
run" (run #f), 4

sal o, 78
Scheme, ix

macros, ix
The Second Commandment, 48
Seres, Silvija, 159
share, 9
short-circuit operators, 159
size-s, 139
Skolem, Thoralf Albert, 8
SLATEX, x
Smullyan, Raymond, 163
Snyder, Wayne, 132
soft-cut operator, 11, 145, 148
Somogyi, Zoltan, 148
Spivey, J. Michael, 159
split o (help function for ÷o), 125
stream, 159
stream-append, 159
string-append, 139
string!symbol, 139

168 Index

Page 177

substitution, 132, 159
reified name, 139

succeed (#s), ix, 3, 159, 160
superscripts. See notational conventions
Suppes, Patrick, 163
surprise o, 58
swappend o, 67

using lambda-limited, 68

teacup o, 14
The Little LISPer, 3
The Little Schemer, ix, 3
The Third Commandment, 147
twin, 31
twins o, 32

without using cons o, 33

unification, 132
unify, 4, 136. See also #

improvements to, 136
unify

!
(unify-check), 140. See also #

!

unit, 159, 160
unnamed functions, x
unnesting a goal, 19

unwrap, 68
unwrap o, 69

with swapped conde lines, 70

Vaillancourt, Dale, 159
value of a run/run" expression, 5
var, 131, 136
var?, 131, 136
variable

anonymous, 131
fresh, 6
lexical, 138
reified, 8

vector, 131
vector (cannot pass to unify), 136
vector?, 131
Voronkov, Andrei, 132

Wadler, Philip L., 159
walk, 133, 134
walk" (walk*), 138
Wand, Mitchell, 159
width (of a number), 102

Index 169

Similer Documents