Peter Siebel - Practical Common Lisp
Здесь есть возможность читать онлайн «Peter Siebel - Practical Common Lisp» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Год выпуска: 2005, ISBN: 2005, Издательство: Apress, Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:Practical Common Lisp
- Автор:
- Издательство:Apress
- Жанр:
- Год:2005
- ISBN:1-59059-239-5
- Рейтинг книги:4 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 80
- 1
- 2
- 3
- 4
- 5
Practical Common Lisp: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Practical Common Lisp»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
Practical Common Lisp — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Practical Common Lisp», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
Recall that NCONC
is the destructive version of APPEND
—it's safe to use an nconc
clause only if the values you're collecting are fresh lists that don't share any structure with other lists. For instance, this is safe:
(loop for i upto 3 nconc (list i i)) ==> (0 0 1 1 2 2 3 3)
But this will get you into trouble:
(loop for i on (list 1 2 3) nconc i) ==> undefined
The later will most likely get into an infinite loop as the various parts of the list produced by (list 1 2 3) are destructively modified to point to each other. But even that's not guaranteed—the behavior is simply undefined.
240
"No! Try not. Do . . . or do not. There is no try." — Yoda, The Empire Strikes Back
241
I'm not picking on Perl here—this example would look pretty much the same in any language that bases its syntax on C's.
242
Perl would let you get away with not declaring those variables if your program didn't use strict
. But you should always use strict
in Perl. The equivalent code in Python, Java, or C would always require the variables to be declared.
243
You can cause a loop to finish normally, running the epilogue, from Lisp code executed as part of the loop body with the local macro LOOP-FINISH
.
244
Some Common Lisp implementations will let you get away with mixing body clauses and for
clauses, but that's strictly undefined, and some implementations will reject such loops.
245
The one aspect of LOOP
I haven't touched on at all is the syntax for declaring the types of loop variables. Of course, I haven't discussed type declarations outside of LOOP
either. I'll cover the general topic a bit in Chapter 32. For information on how they work with LOOP
, consult your favorite Common Lisp reference.
246
Available at http://www.paulgraham.com/spam.html
and also in Hackers & Painters: Big Ideas from the Computer Age (O'Reilly, 2004)
247
There has since been some disagreement over whether the technique Graham described was actually "Bayesian." However, the name has stuck and is well on its way to becoming a synonym for "statistical" when talking about spam filters.
248
It would, however, be poor form to distribute a version of this application using a package starting with com.gigamonkeys
since you don't control that domain.
249
A version of CL-PPCRE is included with the book's source code available from the book's Web site. Or you can download it from Weitz's site at http://www.weitz.de/cl-ppcre/
.
250
The main reason to use PRINT-UNREADABLE-OBJECT
is that it takes care of signaling the appropriate error if someone tries to print your object readably, such as with the ~S FORMAT
directive.
251
PRINT-UNREADABLE-OBJECT
also signals an error if it's used when the printer control variable *PRINT-READABLY*
is true. Thus, a PRINT-OBJECT
method consisting solely of a PRINT-UNREADABLE-OBJECT
form will correctly implement the PRINT-OBJECT
contract with regard to *PRINT-READABLY*
.
252
If you decide later that you do need to have different versions of increment-feature
for different classes, you can redefine increment-count
as a generic function and this function as a method specialized on word-feature
.
253
Technically, the key in each clause of a CASE
or ECASE
is interpreted as a list designator , an object that designates a list of objects. A single nonlist object, treated as a list designator, designates a list containing just that one object, while a list designates itself. Thus, each clause can have multiple keys; CASE
and ECASE
will select the clause whose list of keys contains the value of the key form. For example, if you wanted to make good
a synonym for ham
and bad
a synonym for spam
, you could write increment-count
like this:
(defun increment-count (feature type)
(ecase type
((ham good) (incf (ham-count feature)))
((spam bad) (incf (spam-count feature)))))
254
Speaking of mathematical nuances, hard-core statisticians may be offended by the sometimes loose use of the word probability in this chapter. However, since even the pros, who are divided between the Bayesians and the frequentists, can't agree on what a probability is, I'm not going to worry about it. This is a book about programming, not statistics.
255
Robinson's articles that directly informed this chapter are "A Statistical Approach to the Spam Problem" (published in the Linux Journal and available at http://www.linuxjournal.com/ article.php?sid=6467
and in a shorter form on Robinson's blog at http://radio.weblogs.com/ 0101454/stories/2002/09/16/spamDetection.html
) and "Why Chi? Motivations for the Use of Fisher's Inverse Chi-Square Procedure in Spam Classification" (available at http://garyrob.blogs.com/ whychi93.pdf
). Another article that may be useful is "Handling Redundancy in Email Token Probabilities" (available at http://garyrob.blogs.com//handlingtokenredundancy94.pdf
). The archived mailing lists of the SpamBayes project ( http://spambayes.sourceforge.net/
) also contain a lot of useful information about different algorithms and approaches to testing spam filters.
256
Techniques that combine nonindependent probabilities as though they were, in fact, independent, are called naive Bayesian . Graham's original proposal was essentially a naive Bayesian classifier with some "empirically derived" constant factors thrown in.
257
Several spam corpora including the SpamAssassin corpus are linked to from http://nexp.cs.pdx.edu/~psam/cgi-bin/view/PSAM/CorpusSets
.
258
If you wanted to conduct a test without disturbing the existing database, you could bind *feature-database*
, *total-spams*
, and *total-hams*
with a LET
, but then you'd have no way of looking at the database after the fact—unless you returned the values you used within the function.
259
This algorithm is named for the same Fisher who invented the method used for combining probabilities and for Frank Yates, his coauthor of the book Statistical Tables for Biological, Agricultural and Medical Research (Oliver & Boyd, 1938) in which, according to Knuth, they provided the first published description of the algorithm.
260
In ASCII, the first 32 characters are nonprinting control characters originally used to control the behavior of a Teletype machine, causing it to do such things as sound the bell, back up one character, move to a new line, and move the carriage to the beginning of the line. Of these 32 control characters, only three, the newline, carriage return, and horizontal tab, are typically found in text files.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Practical Common Lisp»
Представляем Вашему вниманию похожие книги на «Practical Common Lisp» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Practical Common Lisp» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.