You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[remove-duplicates](http://clhs.lisp.se/Body/f_rm_dup.htm) returns a
767
-
new sequence with uniq elements. `delete-duplicates` may modify the
771
+
new sequence with unique elements. `delete-duplicates` may modify the
768
772
original sequence.
769
773
770
774
`remove-duplicates` accepts the following, usual arguments: `from-end
@@ -861,9 +865,15 @@ We can use sets functions.
861
865
862
866
We show below how to use set operations on lists.
863
867
864
-
A set doesn't contain twice the same element and is unordered.
868
+
A set doesn't contain the same element twice and is unordered.
869
+
870
+
Most of these functions have recycling (modifying) counterparts,
871
+
starting with "n", e.g.`nintersection` and `nreverse`. The "n" is for
872
+
"non-consing", a lisp parlance for "don't create objects in memory".
865
873
866
-
Most of these functions have recycling (modifying) counterparts, starting with "n": `nintersection`,… They all accept the usual `:key` and `:test` arguments, so use the test `#'string=` or `#'equal` if you are working with strings.
874
+
They all accept the usual `:key`
875
+
and `:test` arguments, so use the test `#'string=` or `#'equal` if you
After this you can press Alt-X on your keyboard and type `slime` and try Common Lisp!
106
117
107
118
(Alt-X is often written `M-x` in Emacs-world.)
@@ -173,7 +184,8 @@ If you can't see it, call `M-x menu-bar-mode RET`.
173
184
174
185
In the terminal version of Emacs (`emacs -nw`), you can open the menu
175
186
with `M-x menu-bar-open`, which is bound by default to `f10`, or use
176
-
the mouse when it is enabled (`(xterm-mouse-mode +1)`).
187
+
the mouse when it is enabled (evaluate `(xterm-mouse-mode +1)` with
188
+
`M-:` or in the `*scratch*` buffer).
177
189
178
190

179
191
@@ -313,7 +325,7 @@ The main shortcut to know is:
313
325
Other bindings which may be useful:
314
326
315
327
-**C-c C-d f** describes a function
316
-
-**C-c C-d h** looks up the symbol documentation in CLHS by opening the web browser. But it works only on symbols, so there are two more bindings:
328
+
-**C-c C-d h** looks up the symbol documentation in Common Lisp Hyper Spec (CLHS) by opening the web browser. But it works only on symbols, so there are two more bindings:
317
329
-**C-c C-d #** for reader macros
318
330
-**C-c C-d ~** for format directives
319
331
@@ -342,7 +354,7 @@ Use `C-c M-m` to macroexpand a macro call
342
354
When you compile and load a file with `C-c C-k` (or a single function
343
355
with `C-c C-c`), and when you have compilation warnings, you don't get
344
356
the interactive debugger. You get the list of warnings inside a
345
-
dedicated "`*slime-compilation*`" buffer that opens up next to your
357
+
dedicated "`*slime-compilation*`" Emacs buffer that opens up next to your
346
358
source file.
347
359
348
360
Each line of your source impacted by a warning will be underlined in red.
@@ -404,7 +416,7 @@ In Slime, you can use the usual `C-c C-k` in an .asd file to compile and load it
404
416
-`M-x slime-rgrep-system`: run `rgrep` on the base directory of a system.
405
417
-`M-x slime-isearch-system`: run `isearch` on the files of a system.
406
418
-`M-x slime-query-replace-system`: run `query-replace` on an ASDF system.
407
-
-`M-x slime-save-system`: save all files belongign to a system.
419
+
-`M-x slime-save-system`: save all files belonging to a system.
408
420
-`M-x slime-delete-system-fasls`: this deletes the cached .fasl files for this system.
409
421
410
422
Sly users have a more featureful `sly-load-system` command that will search the .asd file on the current directory and in parent directories.
@@ -879,13 +891,13 @@ Press `C-u M-(` to enclose it with parens:
879
891
880
892
With a numbered prefix argument (`C-u 2 M-(`), wrap around this number of s-expressions.
881
893
882
-
Additionnaly, use `M-x check-parens` to spot malformed s-exps.
894
+
Additionally, use `M-x check-parens` to spot malformed s-exps.
883
895
884
896
There are additional packages that can make your use of parens easier:
885
897
886
898
-`M-x show-paren-mode`, a built-in Emacs mode: it toggles the visualization of matching parenthesis. When enabled, place the cursor on a paren and you'll see the other paren it matches with. You can initialize it in your Emacs init file with `(show-paren-mode t)`. It is a global minor mode (it will work for all buffers, all languages).
887
899
-**we highly suggest you enable it**.
888
-
- when evil-mode (the vim layer) is enabled, you can use the `%` key to go to the matchin paren.
900
+
- when evil-mode (the vim layer) is enabled, you can use the `%` key to go to the matching paren.
889
901
-`M-x electric-pair-mode`, a built-in Emacs mode: when enabled, typing an open parenthesis automatically inserts the corresponding closing parenthesis, and vice versa. (Likewise for brackets, etc.). If the region is active, the parentheses (brackets, etc.) are inserted around the region instead.
890
902
- you could use [Paredit (animated guide)](http://danmidwood.com/content/2014/11/21/animated-paredit.html) to automatically insert parentheses in pairs,
891
903
- or [lispy-mode](https://github.com/abo-abo/lispy), like Paredit, but a key triggers an action when the cursor is placed right before or right after a parentheses.
Copy file name to clipboardExpand all lines: functions.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Call it:
34
34
~~~
35
35
36
36
The `print` function prints its one argument to standard output *and
37
-
returns it*. "hello world" is thus the returned value of our function.
37
+
returns it*. "hello world!" is thus the returned value of our function.
38
38
39
39
40
40
## Arguments
@@ -193,7 +193,7 @@ We saw that a default key parameter is `nil` by default (`(defun hello
193
193
(name &key happy) …)`). But how can be distinguish between "the value
194
194
is NIL by default" and "the user wants it to be NIL"?
195
195
196
-
We saw how to use a tuple to set its default value:
196
+
We saw how to use a list of two elements to set its default value:
197
197
198
198
`&key (happy t)`
199
199
@@ -283,8 +283,7 @@ Common Lisp has also the concept of multiple return values.
283
283
284
284
### Multiple return values
285
285
286
-
Returning multiple values is **not** like returning a tuple or a list of
287
-
results.
286
+
Returning multiple values is **not** like returning a list of results.
288
287
289
288
#### Quick example
290
289
@@ -714,7 +713,7 @@ NIL
714
713
;; We create a variable:
715
714
CL-USER> (defparameter foo 42)
716
715
FOO
717
-
* foo
716
+
CL-USER> foo
718
717
42
719
718
;; Now foo is "bound":
720
719
CL-USER> (boundp 'foo)
@@ -732,7 +731,7 @@ T
732
731
CL-USER> (function foo)
733
732
#<FUNCTION FOO>
734
733
;; and the shorthand notation:
735
-
* #'foo
734
+
CL-USER> #'foo
736
735
#<FUNCTION FOO>
737
736
;; We call it:
738
737
(funcall (function adder) 5)
@@ -751,7 +750,7 @@ The other cell - sometimes referred to as its _function cell_ - can hold the def
751
750
Now, if a _symbol_ is evaluated, it is treated as a _variable_ in that its value cell is returned (just `foo`). If a _compound form_, i.e. a _cons_, is evaluated and its _car_ is a symbol, then the function cell of this symbol is used (as in `(foo 3)`).
752
751
753
752
754
-
In Common Lisp, as opposed to Scheme, it is _not_ possible that the car of the compound form to be evaluated is an arbitrary form. If it is not a symbol, it _must_ be a _lambda expression_, which looks like `(lambda `_lambda-list__form*_`)`.
753
+
In Common Lisp, as opposed to Scheme, it is _not_ possible that the car of the compound form to be evaluated is an arbitrary form. If it is not a symbol, it _must_ be a _lambda expression_, which looks like `(lambda lambda-list form*)`.
755
754
756
755
This explains the error message we got above - `(adder 3)` is neither a symbol nor a lambda expression.
0 commit comments