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
Copy file name to clipboardExpand all lines: docs/tutorial/informal-introduction-to-lisp.md
+21-21
Original file line number
Diff line number
Diff line change
@@ -225,7 +225,7 @@ Output:
225
225
113.06
226
226
```
227
227
228
-
Like Python, you should treat `*` as read-only. Avoid assigning to it explicitly.
228
+
You should treat `*` as read-only. Avoid assigning to it explicitly.
229
229
230
230
Common Lisp supports other numeric types, including complex numbers. The imaginary unit is represented as `#C(0 1)` or `0+1i`
231
231
@@ -350,13 +350,13 @@ Second line.
350
350
351
351
Common Lisp doesn't have "raw strings" in the same way as Python. Backslashes are always interpreted as escape characters unless they are themselves escaped (e.g., `\\`).
352
352
353
-
String literals can span multiple lines using backslashes at the end of each line to continue the string:
353
+
String literals can span multiple lines without the need for any special syntax:
354
354
355
355
```lisp
356
-
(setf long-string "Usage: thingy [OPTIONS]\
357
-
\
358
-
-h Display this usage message\
359
-
\
356
+
(setf long-string "Usage: thingy [OPTIONS]
357
+
358
+
-h Display this usage message
359
+
360
360
-H hostname Hostname to connect to")
361
361
(print long-string)
362
362
```
@@ -386,47 +386,47 @@ Output:
386
386
There is no automatic concatenation of adjacent string literals in Common Lisp. You must always use `concatenate`.
387
387
388
388
```lisp
389
-
(concatenate 'string "Py" "thon")
389
+
(concatenate 'string "Li" "sp")
390
390
```
391
391
392
392
Output:
393
393
394
394
```lisp
395
-
"Python"
395
+
"Lisp"
396
396
```
397
397
398
398
```lisp
399
-
(setf prefix "Py")
400
-
(concatenate 'string prefix "thon")
399
+
(setf prefix "Li")
400
+
(concatenate 'string prefix "sp")
401
401
```
402
402
403
403
Output:
404
404
405
405
```lisp
406
-
"Python"
406
+
"Lisp"
407
407
```
408
408
409
409
Strings can be accessed by index using `aref`. The first character has index 0:
410
410
411
411
```lisp
412
-
(setf word "Python")
412
+
(setf word "Lisp")
413
413
(aref word 0) ; character in position 0
414
414
```
415
415
416
416
Output:
417
417
418
418
```lisp
419
-
#\P
419
+
#\L
420
420
```
421
421
422
422
```lisp
423
-
(aref word 5) ; character in position 5
423
+
(aref word 2) ; character in position 5
424
424
```
425
425
426
426
Output:
427
427
428
428
```lisp
429
-
#\n
429
+
#\s
430
430
```
431
431
432
432
Indices can't be negative in Common Lisp's `aref`.
@@ -440,17 +440,17 @@ To get a substring (slicing), use `subseq`:
440
440
Output:
441
441
442
442
```lisp
443
-
"Py"
443
+
"Li"
444
444
```
445
445
446
446
```lisp
447
-
(subseq word 2 5) ; characters from position 2 (included) to 5 (excluded)
447
+
(subseq word 2 3) ; characters from position 2 (included) to 3 (excluded)
448
448
```
449
449
450
450
Output:
451
451
452
452
```lisp
453
-
"tho"
453
+
"s"
454
454
```
455
455
456
456
Slice indices have useful defaults; an omitted first index defaults to zero, and an omitted second index defaults to the length of the string:
@@ -462,17 +462,17 @@ Slice indices have useful defaults; an omitted first index defaults to zero, and
462
462
Output:
463
463
464
464
```lisp
465
-
"Python"
465
+
"Lisp"
466
466
```
467
467
468
468
```lisp
469
-
(subseq word 4) ; characters from position 4 (included) to the end
469
+
(subseq word 2) ; characters from position 4 (included) to the end
470
470
```
471
471
472
472
Output:
473
473
474
474
```lisp
475
-
"on"
475
+
"sp"
476
476
```
477
477
478
478
Common Lisp strings *are* mutable. You can change individual characters using `(setf (aref string index) new-character)`:
0 commit comments