UNIX — универсальная среда программирования
UNIX — универсальная среда программирования читать книгу онлайн
В книге американских авторов — разработчиков операционной системы UNIX — блестяще решена проблема автоматизации деятельности программиста, системной поддержки его творчества, выходящей за рамки языков программирования. Профессионалам открыт богатый "встроенный" арсенал системы UNIX. Многочисленными примерами иллюстрировано использование языка управления заданиями
shell.
Для программистов-пользователей операционной системы UNIX.
Внимание! Книга может содержать контент только для совершеннолетних. Для несовершеннолетних чтение данного контента СТРОГО ЗАПРЕЩЕНО! Если в книге присутствует наличие пропаганды ЛГБТ и другого, запрещенного контента - просьба написать на почту [email protected] для удаления материала
.AU
Brian Kernighan
Rob Pike
.AB
.I Hoc
is a simple programmable interpreter
for floating point expressions.
It has C-style control flow,
function definition and the usual
numerical built-in functions such as cosine and logarithm.
.AE
.NH
Expressions
.PP
.I Hoc
is an expression language,
much like C:
although there are several control-flow statements,
most statements such as assignments
are expressions whose value is disregarded.
For example, the assignment operator
= assigns the value of its right operand
to its left operand, and yields the value,
so multiple assignments work.
The expression grammar is:
.DS
.I
expr: number
| variable
| ( expr )
| expr binop expr
| unop expr
| function ( arguments )
.R
.DE
Numbers are floating point.
The input format is
that recognized by @[email protected](3):
.ix [scanf]
digits, decimal point, digits,
.ix [hoc] manual
.ix assignment expression
.ix multiple assignment
@[email protected] or @[email protected], signed exponent.
At least one digit or a decimal point
must be present;
the other components are optional.
.PP
Variable names are formed from a letter
followed by a string of letters and numbers,
@[email protected] refers to binary operators such
as addition or logical comparison;
@[email protected] refers to the two negation operators,
'!' (logical negation, 'not')
and '-' (arithmetic negation, sign change).
Table 1 lists the operators.
.TS
center, box;
с s
lfCW l.
fBTable 1:fP Operators, in decreasing order of precedence
.sp .5
^ exponentiation (s-1FORTRANs0 **), right associative
! - (unary) logical and arithmetic negation
* / multiplication, division
+ - addition, subtraction
> >= relational operators: greater, greater or equal,
< <= less, less or equal,
&== != equal, not equal (all same precedence)
&& logical AND (both operands always evaluated)
|| logical OR (both operands always evaluated)
&= assignment, right associative
.ТЕ
.ix table~of [hoc] operators
.PP
Functions, as described later, may be defined by the user.
Function arguments are expressions separated by commas.
There are also a number of built-in functions,
all of which take a single argument,
described in Table 2.
.TS
center, box;
с s
lfCW l.
fBTable 2:fP Built-in Functions
.sp .5
abs(x) @| x |@, absolute value of @[email protected]
atan(x) arc tangent of @[email protected]
cos(x) @cos (x)@, cosine of @[email protected]
exp(x) @e sup [email protected], exponential of @[email protected]
int(x) integer part of @[email protected], truncated towards zero
log(x) @log (x)@, logarithm base @[email protected] of @[email protected]
log10(x) @log sub 10 (x)@, logarithm base 10 of @[email protected]
sin(x) @sin (x)@, sine of @[email protected]
sqrt(x) @sqrt [email protected], @x sup [email protected]
.ТЕ
.ix table~of [hoc] functions
.PP
Logical expressions have value 1.0 (true) and 0.0 (false).
As in C,
any non-zero value is taken to be true.
As is always the case with floating point numbers,
equality comparisons are inherently suspect. .PP
.I Hoc
also has a few built-in constants, shown in Table 3.
.TS
center, box;
c s s