Add functions for unit displacements in the siz cardinal directions
This change is the "easy" part of #64, but to reduce the amount of duplicated code, this change also modifies the internals of implementing a function. The function identifier is now passed to the implementation as well, allowing many implementations of similar functions to be collapsed more easily.
This commit is contained in:
parent
9670e8b4a1
commit
7e0ba7370d
5 changed files with 673 additions and 688 deletions
224
doc/teapot.lyx
224
doc/teapot.lyx
|
@ -5900,7 +5900,65 @@ env
|
|||
\series default
|
||||
evaluates to the contents of the specified environment variable.
|
||||
If the variable does not exist, then an empty string will be returned.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
above|below|left|right|up|down
|
||||
\series medium
|
||||
[([location
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
l
|
||||
\emph default
|
||||
])] As bare words (without any arguments and also without the parentheses)
|
||||
these symbols return a one-cell displacement in the named direction, e.g.
|
||||
|
||||
\family sans
|
||||
\series bold
|
||||
D
|
||||
\series default
|
||||
(above)
|
||||
\family default
|
||||
\series medium
|
||||
gives the location of the same cell as the current on but in the previous
|
||||
layer and
|
||||
\family sans
|
||||
\series bold
|
||||
R
|
||||
\series default
|
||||
(up)
|
||||
\family default
|
||||
\series medium
|
||||
yields the value of the cell one up from the current cell.
|
||||
With parentheses, they act like
|
||||
\series bold
|
||||
@
|
||||
\series default
|
||||
()
|
||||
\series medium
|
||||
but displaced by one cell in the named direction, so
|
||||
\family sans
|
||||
\series default
|
||||
right()
|
||||
\family default
|
||||
\series medium
|
||||
returns the value of the cell immediately to the right of the current one,
|
||||
and
|
||||
\family sans
|
||||
\series default
|
||||
down(MYTABLE)
|
||||
\family default
|
||||
\series medium
|
||||
gives the value one line down from the cell labeled
|
||||
\family sans
|
||||
\series default
|
||||
MYTABLE
|
||||
\family default
|
||||
\series medium
|
||||
, etc.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
@ -6153,6 +6211,30 @@ x
|
|||
is given in radians.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
below
|
||||
\series medium
|
||||
[([location
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
l
|
||||
\emph default
|
||||
])] displacement by one cell in the positive
|
||||
\series default
|
||||
\emph on
|
||||
z
|
||||
\emph default
|
||||
direction; see the fuller description at
|
||||
\family sans
|
||||
\series bold
|
||||
above
|
||||
\series default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -6385,6 +6467,30 @@ x
|
|||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
down
|
||||
\series medium
|
||||
[([location
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
l
|
||||
\emph default
|
||||
])] displacement by one cell in the positive
|
||||
\series default
|
||||
\emph on
|
||||
y
|
||||
\emph default
|
||||
direction; see the fuller description at
|
||||
\family sans
|
||||
\series bold
|
||||
above
|
||||
\series default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -6809,6 +6915,30 @@ trunc
|
|||
value is returned.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
left
|
||||
\series medium
|
||||
[([location
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
l
|
||||
\emph default
|
||||
])] displacement by one cell in the negative
|
||||
\series default
|
||||
\emph on
|
||||
x
|
||||
\emph default
|
||||
direction; see the fuller description at
|
||||
\family sans
|
||||
\series bold
|
||||
above
|
||||
\series default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -7248,6 +7378,30 @@ x
|
|||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
right
|
||||
\series medium
|
||||
[([location
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
l
|
||||
\emph default
|
||||
])] displacement by one cell in the positive
|
||||
\series default
|
||||
\emph on
|
||||
x
|
||||
\emph default
|
||||
direction; see the fuller description at
|
||||
\family sans
|
||||
\series bold
|
||||
above
|
||||
\series default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -7882,6 +8036,23 @@ x
|
|||
).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
up
|
||||
\series medium
|
||||
[([location
|
||||
\emph on
|
||||
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
l
|
||||
\emph default
|
||||
])] displacement by one cell in the negative
|
||||
\series default
|
||||
\emph on
|
||||
y
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\series medium
|
||||
|
@ -8405,28 +8576,61 @@ func
|
|||
– in the former case it receives an argument count of 0, and in the latter
|
||||
an argument count of -1.
|
||||
So the same symbol can have different semantics depending on which way
|
||||
it is called, but in most cases that would probably be counterintuitive.
|
||||
The no-parentheses form is useful, however, for constants like
|
||||
it is called.
|
||||
In most cases such a difference is counterintuitive, but it seems to work
|
||||
fairly well for the directional
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
e,
|
||||
constants,
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
and it is also used to allow, for example, the names of the functions
|
||||
i.e.
|
||||
bare
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
floor,
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
round,
|
||||
left
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
etc.
|
||||
is the displacement &(-1,0,0), whereas left() is the location one to the
|
||||
left.
|
||||
The no-parentheses form is also useful for constants like
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
e
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
and
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
tau
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
, and it is also used, for example, to allow the names of the functions
|
||||
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
floor
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
round
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
, etc.
|
||||
to be used as keywords for the int() function.
|
||||
\end_layout
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue