Skip to content

Commit 8d78112

Browse files
author
pdn
committed
Merge commit '8953a0e6e11b28cf46e26db2f2c013628c33189d' into devel
2 parents 38e3358 + 8953a0e commit 8d78112

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

examples~snippets.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ written.
1212

1313
~~~~Commonlisp
1414
(defun function-name (param1 param2 &key (keyword1 default-value))
15+
;; keywords are optional; optional positional parameters are also available.
1516
;; implicit progn
1617
)
1718
~~~~
@@ -20,23 +21,23 @@ written.
2021

2122

2223
~~~~Commonlisp
23-
(defmethod method-name ((object class-name)
24+
(defmethod method-name ((param1 class-name))
2425
;; implicit progn
2526
)
2627
~~~~
2728

2829
### Defining a class
2930

3031

31-
Note that DEFCLASS accessor functions for slots can be SETF'd and serve as both getters and setters for the slot.
32+
Note that `DEFCLASS` accessor functions for slots can be `SETF`'d and serve as both getters and setters for the slot.
3233

33-
:INITARG is the keyword used in MAKE-INSTANCE to denote the value of the initial argument (see below).
34+
`:INITARG` is the keyword used in `MAKE-INSTANCE` to denote the value of the initial argument (see below).
3435

35-
:INITFORM is the form used to initialize the slot. Without this, it defaults to `nil`. I favor using nil, 0, "", or
36+
`:INITFORM` is the form used to initialize the slot. Without this, it defaults to `nil`. I favor using `nil`, `0`, `""`, or
3637
`(error "You must set slot <slotname> to a value")` as the usual initform set.
3738

38-
Note that `(:documentation ...)` is the standard documentation mechanism, which can be vuew in the running image with
39-
DESCRIBE (at least in SBCL).
39+
Note that `(:documentation ...)` is the standard documentation mechanism, which can be viewed in the running image with
40+
`DESCRIBE` (at least in SBCL).
4041

4142
~~~~Commonlisp
4243
@@ -107,6 +108,9 @@ are my favorite LOOPs
107108
108109
(loop for i from 0 upto 10
109110
collect i)
111+
112+
(loop for i from 0 below 10
113+
collect i)
110114
111115
(loop for i from 0 upto 10
112116
do
@@ -116,7 +120,7 @@ are my favorite LOOPs
116120
collect
117121
(operate-on ele))
118122
119-
(loop for ele in list
123+
(loop for ele across array
120124
collect
121125
(operate-on ele))
122126
~~~~
@@ -126,13 +130,13 @@ are my favorite LOOPs
126130
The lambda functions is an anonymous function, i.e., unnamed.
127131

128132
Here we map over `numeric-list` and increment each element in it by 1
129-
with `INCF`, returning the incremented list.
133+
with `1+`, returning the incremented list.
130134

131135
~~~~Commonlisp
132136
133137
(mapcar
134138
#'(lambda (x)
135-
(incf x))
139+
(1+ x))
136140
numeric-list)
137141
138142
~~~~
@@ -156,6 +160,8 @@ for details on this very useful form.
156160

157161
### Writing a text file
158162

163+
More complete reading and writing of text files can be done by using the ALEXANDRIA library; these
164+
routines are great for starting to customize your own routine.
159165

160166
```Commonlisp
161167
(defun write-file (filename data)

0 commit comments

Comments
 (0)