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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
107
Fred Brooks, The Mythical Man-Month , 20th Anniversary Edition (Boston: Addison-Wesley, 1995), p. 103. Emphasis in original.
108
Mattel's Teen Talk Barbie
109
Obviously, the size of a number that can be represented on a computer with finite memory is still limited in practice; furthermore, the actual representation of bignums used in a particular Common Lisp implementation may place other limits on the size of number that can be represented. But these limits are going to be well beyond "astronomically" large numbers. For instance, the number of atoms in the universe is estimated to be less than 2^269; current Common Lisp implementations can easily handle numbers up to and beyond 2^262144.
110
Folks interested in using Common Lisp for intensive numeric computation should note that a naive comparison of the performance of numeric code in Common Lisp and languages such as C or FORTRAN will probably show Common Lisp to be much slower. This is because something as simple as (+ a b)
in Common Lisp is doing a lot more than the seemingly equivalent a + b
in one of those languages. Because of Lisp's dynamic typing and support for things such as arbitrary precision rationals and complex numbers, a seemingly simple addition is doing a lot more than an addition of two numbers that are known to be represented by machine words. However, you can use declarations to give Common Lisp information about the types of numbers you're using that will enable it to generate code that does only as much work as the code that would be generated by a C or FORTRAN compiler. Tuning numeric code for this kind of performance is beyond the scope of this book, but it's certainly possible.
111
While the standard doesn't require it, many Common Lisp implementations support the IEEE standard for floating-point arithmetic, IEEE Standard for Binary Floating-Point Arithmetic, ANSI/ IEEE Std 754-1985 (Institute of Electrical and Electronics Engineers, 1985).
112
It's also possible to change the default base the reader uses for numbers without a specific radix marker by changing the value of the global variable *READ-BASE*
. However, it's not clear that's the path to anything other than complete insanity.
113
Since the purpose of floating-point numbers is to make efficient use of floating-point hardware, each Lisp implementation is allowed to map these four subtypes onto the native floating-point types as appropriate. If the hardware supports fewer than four distinct representations, one or more of the types may be equivalent.
114
"Computerized scientific notation" is in scare quotes because, while commonly used in computer languages since the days of FORTRAN, it's actually quite different from real scientific notation. In particular, something like 1.0e4
means 10000.0
, but in true scientific notation that would be written as 1.0 x 10^4. And to further confuse matters, in true scientific notation the letter e stands for the base of the natural logarithm, so something like 1.0 x e ^4, while superficially similar to 1.0e4
, is a completely different value, approximately 54.6.
115
For mathematical consistency, +
and *
can also be called with no arguments, in which case they return the appropriate identity: 0 for +
and 1 for *
.
116
Roughly speaking, MOD
is equivalent to the %
operator in Perl and Python, and REM
is equivalent to the % in C and Java. (Technically, the exact behavior of % in C wasn't specified until the C99 standard.)
117
Even Java, which was designed from the beginning to use Unicode characters on the theory that Unicode was the going to be the character encoding of the future, has run into trouble since Java characters are defined to be a 16-bit quantity and the Unicode 3.1 standard extended the range of the Unicode character set to require a 21-bit representation. Ooops.
118
Note, however, that not all literal strings can be printed by passing them as the second argument to FORMAT
since certain sequences of characters have a special meaning to FORMAT
. To safely print an arbitrary string—say, the value of a variable s—with FORMAT
you should write (format t "~a" s).
119
Once you're familiar with all the data types Common Lisp offers, you'll also see that lists can be useful for prototyping data structures that will later be replaced with something more efficient once it becomes clear how exactly the data is to be used.
120
Vectors are called vectors , not arrays as their analogs in other languages are, because Common Lisp supports true multidimensional arrays. It's equally correct, though more cumbersome, to refer to them as one-dimensional arrays .
121
Array elements "must" be set before they're accessed in the sense that the behavior is undefined; Lisp won't necessarily stop you.
122
While frequently used together, the :fill-pointer
and :adjustable
arguments are independent—you can make an adjustable array without a fill pointer. However, you can use VECTOR-PUSH
and VECTOR-POP
only with vectors that have a fill pointer and VECTOR-PUSH-EXTEND
only with vectors that have a fill pointer and are adjustable. You can also use the function ADJUST-ARRAY
to modify adjustable arrays in a variety of ways beyond just extending the length of a vector.
123
Another parameter, :test-not
parameter, specifies a two-argument predicate to be used like a :test
argument except with the boolean result logically reversed. This parameter is deprecated, however, in preference for using the COMPLEMENT
function. COMPLEMENT
takes a function argu-ment and returns a function that takes the same number of arguments as the original and returns the logical complement of the original function. Thus, you can, and should, write this:
(count x sequence :test (complement #'some-test))
rather than the following:
(count x sequence :test-not #'some-test)
124
Note, however, that the effect of :start
and :end
on REMOVE
and SUBSTITUTE
is only to limit the elements they consider for removal or substitution; elements before :start
and after :end
will be passed through untouched.
125
This same functionality goes by the name grep
in Perl and filter
in Python.
126
The difference between the predicates passed as :test
arguments and as the function arguments to the -IF
and -IF-NOT
functions is that the :test
predicates are two-argument predicates used to compare the elements of the sequence to the specific item while the -IF
and -IF-NOT
predicates are one-argument functions that simply test the individual elements of the sequence. If the vanilla variants didn't exist, you could implement them in terms of the -IF versions by embedding a specific item in the test function.
Интервал:
Закладка:
Похожие книги на «Practical Common Lisp»
Представляем Вашему вниманию похожие книги на «Practical Common Lisp» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Practical Common Lisp» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.