Skip to content

Commit a906ab2

Browse files
authored
Merge pull request #42 from mar444/fix
chapter3: fix table typo
2 parents 66134f6 + dd8eabd commit a906ab2

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

PAIP.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,9 +3856,9 @@ we just take the cdr of the result returned by assoc.
38563856
(setf state-table
38573857
'((AL . Alabama) (AK . Alaska) (AZ . Arizona) (AR . Arkansas)))
38583858

3859-
> (assoc .. state-table) ^ (AK . ALASKA)
3859+
> (assoc 'AK state-table) => (AK . ALASKA)
38603860

3861-
> (cdr (assoc *AK state-table)) ^ ALASKA
3861+
> (cdr (assoc 'AK state-table)) => ALASKA
38623862

38633863
> (assoc 'TX state-table) => NIL
38643864

@@ -3884,13 +3884,13 @@ make-hash-tab! e and modified with a setf of gethash:
38843884
(setf table (make-hash-table))
38853885

38863886
(setf (gethash 'AL table) 'Alabama)
3887-
(setf (gethash .. table) 'Alaska)
3888-
(setf (gethash .. table) 'Arizona)
3887+
(setf (gethash 'AK table) 'Alaska)
3888+
(setf (gethash 'AZ table) 'Arizona)
38893889
(setf (gethash 'AR table) 'Arkansas)
38903890

38913891
Here we retrieve values from the table:
38923892

3893-
> (gethash .. table) ^ ALASKA
3893+
> (gethash 'AK table) => ALASKA
38943894
> (gethash 'TX table) => NIL
38953895

38963896
The function remhash removes a key/value pair from a hash table, cl rhash removes
@@ -3928,13 +3928,13 @@ with a setf form. A table would be built as follows:
39283928

39293929
(setf (get 'AL 'state) 'Alabama)
39303930

3931-
(setf (get .. 'state) 'Alaska)
3932-
(setf (get .. 'state) 'Arizona)
3931+
(setf (get 'AK 'state) 'Alaska)
3932+
(setf (get 'AZ 'state) 'Arizona)
39333933
(setf (get 'AR 'state) 'Arkansas)
39343934

39353935
Now we can retrieve values with get:
39363936

3937-
> (get .. 'state) => ALASKA
3937+
> (get 'AK 'state) => ALASKA
39383938
> (get 'TX 'state) => NIL
39393939

39403940
This will be faster because we can go immediately from a symbol to its lone property
@@ -3956,9 +3956,9 @@ symbol - pi i st (which gives a symbol's complete property list):
39563956
(setf (symbol-piist 'state-table)
39573957
'(AL Alabama AK Alaska AZ Arizona AR Arkansas))
39583958

3959-
> (get 'state-table 'AD => ALASKA
3959+
> (get 'state-table 'AK) => ALASKA
39603960

3961-
> (get 'state-table 'Alaska) NIL
3961+
> (get 'state-table 'Alaska) => NIL
39623962

39633963
Property lists have a long history in Lisp, but they are falling out of favor as new
39643964
alternatives such as hash tables are introduced. There are two main reasons why

docs/chapter3.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,9 +1197,9 @@ we just take the cdr of the result returned by assoc.
11971197
(setf state-table
11981198
'((AL . Alabama) (AK . Alaska) (AZ . Arizona) (AR . Arkansas)))
11991199

1200-
> (assoc .. state-table) ^ (AK . ALASKA)
1200+
> (assoc 'AK state-table) => (AK . ALASKA)
12011201
1202-
> (cdr (assoc *AK state-table)) ^ ALASKA
1202+
> (cdr (assoc 'AK state-table)) => ALASKA
12031203
12041204
> (assoc 'TX state-table) => NIL
12051205
@@ -1224,13 +1224,13 @@ make-hash-tab! e and modified with a setf of gethash:
12241224
(setf table (make-hash-table))
12251225

12261226
(setf (gethash 'AL table) 'Alabama)
1227-
(setf (gethash .. table) 'Alaska)
1228-
(setf (gethash .. table) 'Arizona)
1227+
(setf (gethash 'AK table) 'Alaska)
1228+
(setf (gethash 'AZ table) 'Arizona)
12291229
(setf (gethash 'AR table) 'Arkansas)
12301230

12311231
Here we retrieve values from the table:
12321232

1233-
> (gethash .. table) ^ ALASKA
1233+
> (gethash 'AK table) => ALASKA
12341234
> (gethash 'TX table) => NIL
12351235
12361236
The function remhash removes a key/value pair from a hash table, cl rhash removes
@@ -1267,13 +1267,13 @@ with a setf form. A table would be built as follows:
12671267

12681268
(setf (get 'AL 'state) 'Alabama)
12691269

1270-
(setf (get .. 'state) 'Alaska)
1271-
(setf (get .. 'state) 'Arizona)
1270+
(setf (get 'AK 'state) 'Alaska)
1271+
(setf (get 'AZ 'state) 'Arizona)
12721272
(setf (get 'AR 'state) 'Arkansas)
12731273

12741274
Now we can retrieve values with get:
12751275

1276-
> (get .. 'state) => ALASKA
1276+
> (get 'AK 'state) => ALASKA
12771277
> (get 'TX 'state) => NIL
12781278
12791279
This will be faster because we can go immediately from a symbol to its lone property
@@ -1295,9 +1295,9 @@ symbol - pi i st (which gives a symbol's complete property list):
12951295
(setf (symbol-piist 'state-table)
12961296
'(AL Alabama AK Alaska AZ Arizona AR Arkansas))
12971297

1298-
> (get 'state-table 'AD => ALASKA
1298+
> (get 'state-table 'AK) => ALASKA
12991299
1300-
> (get 'state-table 'Alaska) NIL
1300+
> (get 'state-table 'Alaska) => NIL
13011301
13021302
Property lists have a long history in Lisp, but they are falling out of favor as new
13031303
alternatives such as hash tables are introduced. There are two main reasons why

0 commit comments

Comments
 (0)