Functional stream computer. Flows and their processing in structure of expression
Article continues (the beginning – Sections 2 and 3) the project not of fon_neymanovsky structure of a stream computer with parallel processing of data streams and expressions (programs) in the form of dynamically rebuilt structure of collective of microprocessors (transputers) for structure of the next expression – superposition of functions. Here the primitives of the organization of structure of data streams naturally solving problems of synchronization of flows, their separations on properties of elements, methods of formation and processing are offered (complete review to 15.08-2013 g)
Content |
Links to all sections of the project:
1. Functional Stream Mashina with parallel computings. Introduction (http://tadviser.ru/a/121275)
2. Uniform data structure and programs (http://tadviser.ru/a/149691)
3. Functioning of FPM. Expressions of language of programming
(http://tadviser.ru/a/149691)
4. Flows and their processing in structure of expression
(http://tadviser.ru/a/150588)
5. Micro programming of functions
(http://tadviser.ru/a/153069)
6. The program as the managed flow of expressions
(http://tadviser.ru/a/153069)
7. Macro definitions of the user functions (http://tadviser.ru/a/157631)
4. Flows and their processing in structure of expression
Let's remind that expression of the FPM language before execution is developed in similar SA, on structure (a tree from the connected micro computers)
matching structure of expression to within macro definitions and the additional exits of functions determined by a primitive of _Out (item 4.2.3).
Therefore speaking about flows on inputs and exits of functions of expression, we mean flows in the relevant SA. To implementing in SA of function
the micro computer as usual - is connected the _Calc calculator (the unified micro computer) executing as usual processing
parameters (item 3.4.1.2), entrance and vykhody flows of functions by means of the transactions _Calc (formulas, primitives of _If, the transaction _Break, _Skip, etc.),
the "transparent" arguments entered by the user into structure (in any place among the main arguments) functions. Moreover, similar image,
however taking into account the nature of specific function directly the same _Calc sometimes executing the main is connected to its transactions
function transactions (for example, $Sync) by default (lack) of the transactions _Calc among her arguments
At last, we will pay attention to structure of a flow (item 2.5) in which each element can have own properties (item 2.4). It agrees
to it in a flow elements - directly atoms (% \%) or links to structures in Dynamically Distributed (uniform) Memory (DRP) move
in the form of R-(% @ %) or V-(%&%) of values together with their properties and properties of the data structures and expressions specified by them in DRP.
4.1. Generators of flows
It is clear, that in structure of expression there have to be sources of flows - their generators. Values of arguments of generators can be
or to be calculated by literals (behind an exception * Lit). If the argument of the generator creates a flow, as unary
(only) value the first element of a flow which then is interrupted (_Break) is accepted. Most part of generators
(except * Stream and * Lit) arguments determine as (functions) parameters with the fixed names which can be controlled,
process and change according to item 3.4.1.2. So nothing prevents to set in this case the required All parameter (quantity) as a layer
and when processing to replace its layer value with a number of elements in this layer. The generated flows can be processed, as well as
output flows of any function and the same means of item 4.2. Moreover, as well as obychnvya function the generator upon completion of the generated flow
reports its termination without properties (%%).
4.1.1. The simplest generators of flows
1) * Stream (<аргумент><b,{}) </b><аргумент>there are calculated unary (item 6.1) values of arguments as their priority
(from left to right) move on a function exit. At the same time arguments - literals atoms are copied (are led to a type of % \%).
In case of agument of literals - layers and nodes their R-values – links UKA and UKS are copied
Examples of generation of flows: * Stream (1,2,3,#) -1, 2, 3, (atoms of % of \.9+ %, item 2.2.2) and # - indefinite value *Stream(1.,2.1,3.3,5(6)) - 1., 2.1, 3.3 (%./%) и 5(6) - - R-value (% @.9+, %) *Stream(1,2,3,*Stream(4,5,6)) - 1, 2, 3 (%\.9+%), 4 (@.9+~,%)
2) * Lit ({,}) <аргумент><аргумент>- Action is similar * to Stream (see above) with only that difference that everyone
the argument of NE is calculated, and is defined as a literal which R-value - links UKA and UKS to argument value in brought
expression * Lit are copied on the output of the generator with additional property '?' protection.
Examples of generation of flows: * Lit(1,2,3) -1,2,3 (R-values of atoms, % @.+? ~, %) *Lit(1,2,3,5(6)) - 1, 2, 3 (@%.+?~,%), 5(6) (%@.+?,?%) *Lit(1,2,3, *Stream(4,5)) - 1, 2, 3 (@%.+?~,%),*Stream(4,5) ( %@.*?,?%)
Attention! – Compare these examples to similar in (1)
4.1.2. The configured flow generator Row
_Row([ From:] ,[ All:][ ,])<выражение><Количество><операции>
Difference of "operations" from similar with item 3.4.1.2 in the following:
1) The calculated expression (the first member of a flow and only!) and perhaps corrected as the From parameter (item 3.4.1.2) before execution of operations
is located in the register '!'
2) Transactions repeat over the register '!': every time this register by the beginning of transactions contains the last calculated value
register '!', NE which is surely sent to an exit because of the transaction _Skip. Anyway on completion of the next transaction $i counter
increases by 1
3) At each sending a new element (value '!') the value of the register of $n increases by an exit automatically on 1 (the counter
members of the generated row) and the copy of this element (atom, R-or V-value) remains in the register of $e initially without properties (%%),
available in transactions of generation of the following element. Registers of $iб $n and $e are kept automatically and their adjustment
transactions NOT allow
4) For lack of _Break generation is resumed (repeats) until the value of $n reaches All value. In this case
in the register '!' the code of the termination with otsunstviyem properties arrives (%%) and transactions repeat over this register last time,
what allows to create in it value of the adder (the register of $S and not only).
4.1.2.1. Sale of the generator of a flow Row by default "transactions"
This implementation only in SA:
<выражение><Количество>*Row(From:,All:, _Par(All:{_If(%.9+~,%,`!%\.%->!`,_Go),`1->!`}, FROM:{_If(%&%,`!%&@%;.->!`)} ), `` )
1) If All is not whole positive, then operations on its conversion (_Par primitive) set it in 1. Otherwise All
Atom is given to a type (% \. %). This implementation of processing of the All parameter is entered by its default and only into SA, differently into this expression
operations of the user with the analysis and the All conversion are located
2) In case of V-value (%&%) the FROM (_If) parameter in the register '!' this V-value copy it in the register '.' with the requirement
(%&@%) existence of the R-value specified by it. For lack of the last it is created indefinite similarly macro $Sel (item 4.3.2) and then
the initial V-value, but already having indefinite R-value specified by it, place (->) in the register '!' - new value
FROM parameter
3) Owing to item 4.1.2 (1-2) by default of transactions * Row repeats All of times an empty formula (without the transactions _Calc), repeating transfer
register contents '!' with perhaps corrected original value (2) FROM parameters
4.1.2.2. Macro definitions based on the flow generator Row
These are implementations of the following built-in macro definitions:
1) * Num ([All:] <Количество>[[Step:]<шаг>] [[From:]<Начало>]) – generates a flow
- a number sequence from starting value of From, 0 - by default or not whole, with the specified All and the set Step step
(by default 1): on an exit it is issued<Начало>, then<Количество>-1 time<шаг> is added to the last generated value. Is implemented as follows only in SA:
<выражение><Количество><шаг>*Row(From:,All:[,Step:], <>_Par(All:{_If(%~.,%,!->!,_Go),_If(%.9+~,%,`!%\.%->!`,_Go),`1->!`}, From:{_If((%.9~,%,%./~,%),`!%\.%->!`,_Go),`0->!`}, Step:{_If((%.9~,%,%./~,%),`!%\.%->!`,_Go),`1->!`} ), { _If (%%, _Go), '$n', _if (%.9 ~ 0%,'!+ =Step')', $S+=!' } / At <>$n0 '!' grows on Step/ )
Let's note only that the All parameter can it is set by a layer and in this case as All it is used by the layer size (quantity of elements).
The counted amount of $S the generated row can be placed in a subspace by means of _Sum primitive - a transparent argument
macro * Num (item 4.4).
Examples of generation of flows: *Num(From:1,All:5) - 1, 2, 3, 4, 5 (%\.9+%) *Num(5,-1,5) - 5, 4, 3, 2, 1 (%\.9+%) *Num(5,2) - 0, 2, 4, 6, 8 (%\.9+2%)
2) * Fact ([All:]<Количество>) – generates a flow from factorials of numbers of a natural row:
<Количество>*Row(From:1,All:, _Par(All:{_If(%.9+~,%,`!%\.%->!`,_Go),`1->!`}), {_If(%%,_Go),`$n`,_if(%.9~0%,`$n+1;*$e;->!`),`$S+=!`} ) Example of generation of a flow of factorials: *Fact(5) - 1, 2, 6, 24, 120
2) * Degree ([Base:] <Основание,[ All:]<Количество>) – generates a flow from degrees 1, 2..., All background:
<Количество><основание>*Row(From:1,All:,Base:, _Par(All:{_If(%.9+~,%,`!%\.%->!`,_Go),`1->!`}, Base:{_If((%.9~,%,%./~,%),`!%\.%->!`,_Go),_Break} ), _If(%~%,`Base*!;->!;$S+=!`) ) Example of generation of a flow of degrees with the basis 2: *Degree(2,5) - 2, 4, 8, 16, 32
4.1.3. Generation of V-values of a layer
* Sel ([Struct:]<слой[R-значение]> [_More]) – generation of V-values of elements of a layer on UKS of processed (Struct)
R-values in the presence of _More in ascending order of the elements (their atoms) specified by these V-values, differently (_More is lowered) as it should be
followings in the layer. There is an ability to manage sorting of V-values (more precisely, the R-values of a layer specified by them) use
transactions _If and formulas _Calc. This possibility is considered together with function of $Merge merge of Sel generated * (etc. functions) flows
(item 4.3.4). In the same place also about the generator * Sel is more detailed
4.1.4. Tree traversal of structure on a circuit
* Tree ([Struct:] <Структура>[[Deep:]</b><глубина>]) - generation of V-values of elements (tops) of a tree structure (tree)
in process and an order of its bypass on a circuit from top to down on UKS and from left to right in a layer with the set restriction on number of passable
levels of structure at the movement down UKS. In effect it is the scheme from classical "from top to down and from left to right" only the fact that V-values
tops - elements of a layer form only once at the first achievement of top. Deep is whole or is given rounded) to
whole. The maximum allowed Deep value - 26. Any other value of this parameter, perhaps after conversions by transactions of item 3.4.1.2,
it is automatically replaced with 26. The minimum Deep=1 value and in this case action * to Tree is identical * to Sel (item 4.1.1) for lack of parameter
_More.
Let's consider in more detail operation of the generator * Tree using the transactions _Calc allowing Not only to receive V-values of tops of structure
in the course of its bypass but also to process these tops taking into account their communication on levels of an iyererakhiya of structure, for example, having executed certain
calculations, but even to make changes to structure in the course of its bypass. Also implementation process of this bypass will become in passing more clear:
1) Function * Tree will organize a bypass of structure, using a stack which contains a route - a way on structure from some top - V-value
element (stack bottom) of a layer on UKS of initial structure (Struct parameter) to V-value of passable top - stack tops. Originally
in a stack one element - V-value of the layer element first at the left on UKS (UKS, index 0) of initial structure is located (Struct parameter).
Then following actions:
a) In the presence of UKS on not an empty layer in the R-value specified by V-value of top of a stack the V-value<УКС, индекс 0> and it forms<УКС, индекс 0>
the new V-value is located in stack top (fills up it): actually it is transition to one level down. This action is blocked and at once
to (b) if the number of levels (number of V-values in a stack) reached Deep value.
b) In the absence of UKS on NOT the empty layer in the R-value specified by V-value of top of a stack the attempt in this V-value becomes
<УКС,индекс> increase value of the index by 1 - to pass to the following element of a layer on UKS V-values.
c) If the attempt (b) is unsuccessful - there is no following element of a layer, then from top of a stack is pushed out - the V-value and return is removed
to action (b) if, of course, the stack of NE is empty. Otherwise the bypass of structure comes to the end.
2) In a stack, beginning from its top and to its bottom elements hereinafter are referred to (are identified) in formulas _Calc as a, b, c...
As well as in case of a train of change of these elements - NE V-values are allowed, however transactions of formulas (river 5) allow change
the atoms specified by them (V-values), and in case of the stack of an and a layer of R-value which is in top.
3) As well as in case of transactions with trains (item 4.3.2) all types of representation of _If, including are allowed (4-1) here
4) As well as in case of transactions with trains (item 4.3.2(4)) here the formula _Calc (river 5) may contain a cycle (to begin '*>' or '*<') - повторяться
for each of the stack elements 'a ' '-z' (as before a train)
5) Transactions repeat every time at emergence in top of a stack of new V-value (passable top) and once again upon termination of a bypass,
when the stack becomes empty
6) By the beginning of transactions the register '!' contains the copy of V-value of top of a stack or the code of the end of transactions without properties (%%). As usual
the transaction _Skip blocks issue of value of the register '!' on an exit of function and accomplishment of the subsequent to it of transactions, causing further
actions of function in a bypass of structure. The transaction _Break, as usual, interrupts all transactions of function, including a bypass of structure. Before issue on
exit of function of transaction can correct register contents '!'. On the other hand canceling by means of _Skip of value of the register
'!' on an exit NE cancels executed by transactions (to _Skip) changes in structure of Struct
7) At replenishment of a stack new V-value this element in top of a stack purchases dynamic property '>' (item 4.5). In a case
successful implementation (1b) this property is removed and replaced with dynamic property '='. If it was preceded by actions (1v),
that in addition the top of a stack purchases property '<'.
8) Elements in a stack are deprived by Otsustvuyushchiye (specified by names) properties (%%)
9) Transaction a ++ formulas _Calc causes actions (1b) with all that it implies. At the same time anyway the subsequent to this
are executed by transaction of a formula and _Calc NOT similar to _Skip. However at the same time naturally there is no transition down (on hierarchy) on UKS
The R-value specified by initial V-value (before transaction a ++) 'a', i.e. passes a branch (subtree) with a root in
'a'
10) Similarly * Row (item 4.1.2) uses registers of $S and $n. Are in addition entered, as well as $n automatically created registers of $l
- a number of elements in a stack (levels) and $i - value of the V-values index of top of a stack
4.2. Management of flows out of functions
Actually, this management is implemented by primitives of the setup _Out, _Chanal, etc. (river 4), included in structure of function arguments and together
with that as usual regardless of the executed transactions (built in by MT) this function. These primitives are "transparent"
arguments for function: can take place in any order among her other arguments
4.2.1. Control and conversion of entrance flows
These transactions syntactically are defined and will be organized also, as well as in case of function parameters (item 3.4.1.2):
<Имя входного потока>:<операции>,{<Имя входного потока>:<операции>}
The difference is as follows:
1) The primitive of _Par NOT is used: only his arguments (2) as transparent function arguments
2) Instead of a name of parameter name a, b, c is used... the input (argument) of function creating a flow, defined
as their following from left to right in a layer of arguments
3) Transaction" _Skip organizing the admission (ignoring by function) an element of an entrance flow is in addition entered "actually (it NE
is accepted on processing), and _End interrupting the corresponding flow with formation of sign of end of a flow (an element without properties).
4) _If (<условие>) or _if (<условие>) causes the transaction _Skip (by default) at Failure of consideration: value of the register'!' or
'.' does not answer any of Properties of a condition. Otherwise the transaction _Go is executed
5) The analysis and, perhaps, transactions (a number of transactions) repeat for each next element of an entrance flow with the entered name
(an argument name index with transactions). Value of this element with its properties, including matching a name of an entrance flow
additional property, are located in the register '!' by the beginning of execution of operations. Received as a result of calculations
(perhaps initial without changes) value of the register '!' it is transferred to function processing if before not the ball one is executed of
transactions _Skip, _End or _Break
6) Upon termination of a flow the sign of end of a flow is processed by the considered transactions as a normal element without properties (%%).
7) In formulas quality of an operand the register of $S (adder), $i quantity arrived and $n - quantity of the elements accepted on processing can be used
flow, unlike other registers saving the value upon transition from one element of an entrance flow to the following (its processing).
Its original value of registers is equal 0 by the beginning of receipt of a flow. The value of $S from an element of a flow adjusts (transactions) here
the user, and value of $i and $n automatically increases by 1 for next, respectively, arrived and accepted (transferred
functions) to processing of an element and NE it can be changed. Values of these registers can be used as for formation of the next value
(register'!'), transferred to processing, so value on completion (5) of processing of a flow for issue in addition on a function exit
results on an entrance flow together (not necessarily) with additional property '!' (Result)
8) The element (the copy of atom, R-or V-value) accepted on processing remains and can be used in as $e operand in formulas
processings of the following element of a flow. Initial (before acceptance of the first element) $e is not present matters properties (%%). Correction of $e,
as well as $i and $n NE is allowed
9) As well as earlier (item 3.4.1.2) as an operand in formulas can use names of function parameters.
According to (5) transaction can change the accepted flow element - the register '!' (including the code of end) calculated from it or without it other value, for example:
a:{_If(%*0%,`0->$S`),_If(%~%,`$S++`,_Skip),`$S(%.9!%)->!`}
In this example for an initial element of a flow in the register of $S a flow 0 is located: in this transaction generally speaking there is no sense because the Register of $S by the beginning of receipt of a flow by default is always established in 0. If it is NE termination of a flow (the % ~ % - is some properties), then the value of the register of $S increases by 1 ($S ++) and the transaction _Skip will organize the admission of the accepted element in a flow. Otherwise (end of a flow
- the element without properties - %%) is executed the last transaction (formula) substituting this element'!' (the code of end) value of $S -
number of elements in a flow, filling up it with property of %! % (a result on a flow).
4.2.2. Processing of elements of an output flow of function
Syntax:
<операции>Out: (4-1)
Processing of the elements created by function on it syntactically the defined (main) exit is executed to its identically additional exits,
the set primitive of _Out (item 4.2.4). Moreover, this processing can be integrated with processing on additional exits,
having included (4-1) in structure of parameters of a primitive of _Out (item 4.2.3). It is clear, that imya_indeks Out cannot be used as a parameter name
function or channel
And in conclusion still the simplest examples with processing of an output of the generator * Sel on p 4.1.1:
Selection of a subspace layer with name X of V-values of elements with atoms - whole positive: * Sel (X, Out: { _If (% of.9+ %,_Go), _Skip } – with a complete definition of a condition choice and transactions * Sel (X, Out: _If (% of.9+ %) – the same, but well agrees (4) * Sel (X, Out: %.9+ %) – the same, but is even shorter according to item 3.4.1.2(5) * Sel (X, Out: %V |.9+ %) – to select V-values of elements with names indexes
4.2.3 Additional exits of function
In addition to the main thing - syntactically the defined exit of function it is possible to define also its additional exits connected with of the same name to these exits channels (item 4.2.4). These exits (output flows) are defined and processed to identically entrance flows (item 4.2.1) the only primitive included in structure of arguments (on any place) functions:
Syntax: <Имя выхода><операции><Имя выхода><операции>_Out(:,{:}) (4-2)
The difference consists only that:
1) It is processed (the register '!' in formulas) an element not of an entrance flow, and the next element created by function and sent
(copies of atom, R-or V-value) on all exits, including main. And in the same way registers of $S, $i and $n for a flow are used own
created at each exit (main and additional) data. Similar to $e defines previous transferred to a function exit
element
2) Upon termination of work of function on exits the sign of end - an element without properties (%%) actually arrives as also a case
processings of an entrance flow
3) _Out: (Out:<Операции>) Out is equivalent: <Операции>that it is shorter and more clear (see examples of item 4.2.2).
Attention! Owing to item 4.2.2 the name Out defines processing of elements of the main exit of function and therefore NE can be used in quality
name of the channel (item 4.2.4) or function parameter
4.2.4 The channel on a function input
<Имя[-индекс] канала>:_Сhanal>
%.|%
– as an argument of any function announces its input connected with the additional exits (item 4.2.3) of the same name of other functions
in the same expression, announced by a primitive _Out. – From these exits elements on an input with _Chanal (merge of flows) arrive. – Primitive
_Chanal is defined only on inputs of the functions allowing the flows processed by them. At this _Chanal and _Out exits connected with it
should is (a) in one branch of a tree of expression (SA) performed by function of $Eval (b) for lack of finding of _Chanal and of the same name
_Out on a route from a root (basis) of this branch down hierarchy levels.
In a layer of function arguments there can be several channels and it is clear with names, unique within a layer, because it is names indexes.
These names are unique within the expression performed by $Eval and can be practically any and even matching names of functions,
determined by the user and even with parameters of the built-in functions of the same expression
P.S. It is easy to guess that means of item 4.2.2 - item 4.2.4 allow to organize separation of one flow into several others, for example
on structure of properties of their elements - actually to implement the separator
4.2.5 Divider of the main exit of function
The output flow of function can be distributed on different channels (item 4.2.4), having included in a layer of her arguments a primitive ("transparent"
argument):
<Направление><Направление>_Del({,}) <Направление><Имя канала>::= |Out|<Неопределенный элемент [#]>
Elements of an output flow of function as their priority will go to these Directions as their determination from left to right among arguments there is _Del and then cyclically again in the same poryad from the 1st to the last at the left on the right. For lack of the channels specified by names or indefinite (#) Directions the corresponding elements of a flow are simply lost (item 4.2.4). In case of the Out direction an element as usual arrives on the main Exit of function
* Num (5, From: 1, _Del (Out) - generates 1, 3, 5 (odd) * Num (5, From: 1, _Del (#,Out) - generates 2, 4 (even) * Num (9, From: 1, _Del (#,,Out) - generates 3, 6, 9 (every 3rd from 1 to 9)
4.3. Stream handling techniques functions
Here the following main modes of processing described below are used by different functions
4.3.1. Any processing
It is the only function of $NoOut which ignores entrance flows in any quantity, as well as any
own parameters, issues nothing on own main (syntax defined) an exit, blocks determination
means according to item 4.2.1-3. At the same time this nothing this not doing function creates the following benefits:
1) All her arguments (expressions) function absolutely independently of each other if, of course, do not communicate between
channels (Out-> Chanal)
2) $NoOut can be used in quality (and not one) the transparent argument of any function working irrespective of others
arguments of the same function and not affecting result of its calculations, besides if opaque function arguments of NE are connected by channels with
arguments of transparent $NoOut.
3) Moreover, in this case the transparent argument of $NoOut NE influences also for the period of function evaluations with such argument: at the end
calculations the branch of SA with top (basis) of $NoOut is selected in an autonomous part of SA and continues (arguments $NoOut) calculations,
and expression with the function containing $NoOut argument completes calculation and is removed from SA
4.3.2. Synchronous processing of several data streams
This processing is made by the only function of $Sync by means of the means of its setup considered here allowing to enter
the built-in macro definitions and also to the user own macro definitions implemented in SA through $Sync (and $Eval, river 10).
The central concept is "train" here - a set of the next elements which arrived on one of all entrance flows (inputs) of function.
Elements of a train are identified to identically corresponding inputs of function from left to right: a, b, c..., z,
i.e. the maximum quantity of such inputs of function and, respectively, the train size - 26. After exhaustion (termination) of one of flows
the value of its element of the same name in the next train remains from the previous train, i.e. it is the last element of a complete flow.
On end of all entrance flows also the work of function with removal of the branch (subtree) of SA corresponding to it is completed.
Processing of trains is made by means similar to already considered for input (item 4.2.1) and days off (item 4.2.3) of flows. Difference
is as follows:
1) Transactions or their row (in {}) are entered directly as "transparent" function arguments. At the same time in addition to a normal type of _If with a condition
- properties of the register '!' this primitive can have also more difficult appearance:
<Имя входного потока><условие><Имя входного потока><условие>_If(:{,:} (4-1) [,<операция>]) <условие>::= <Свойства>|(<Свойства>{,<Свойства>})
According to syntax of structure "name of an entrance flow" (a-z) is a name index and therefore it is unique in limits
layer of arguments of a primitive of _If. The element of this flow placed in a train should correspond - to have the properties specified in one
from the Properties atoms specified for this element. Let's remind that such check regardless of values of elements of other input
flows it is possible to execute when processing an entrance flow (item 4.2.1). However the additional version of _If requires simultaneous compliance
elements of different flows (train) to certain conditions (existence of certain properties), at which by default "actually transactions"
_Go is understood.
2) Original value of the register'!' (result of calculations - processings of the next train) by the beginning of processing of a train is established
equal to the copy of a parameter value of From of function, by default empty layer () % ~., 0%.
3) As operands of transactions in a formula are in addition used names (a, b, c...) train elements
(function inputs) and also' ^' - the link to a train element defining value of this element and its property as well as
at the address to him by name. At the beginning of processing of a train this link ustanavalivatsya on an element 'a' of a train. NE is allowed
change of values and properties of elements of a train directly or through the link '^'. There are (river 5) transactions _Calc
(river 5) on change - movement of this link on train elements
4) The description of member properties of a train precedes in the list of "Property" we designate it to the general properties - atom (% \%), V-or R-value: at first
as property the name (3) elements in a train which can be followed by property '^' is entered if this element
repeats from the previous processed train (the corresponding input flow is complete)
5) The formula here has internal (in the characters limiting it) structure:
[<цикл>]<операция _Calc,[п.5.2]>{,<операция _Calc>} <цикл>::= <По элементам кортежа от 'a' к 'z'> [ *> ] <цикл>::= <По элементам кортежа от 'z' к 'a'> [ *< ]
The formula beginning '*' repeats in turn (cycle) for each element of a train in turn selected from left to right (*>
- from 'a' to 'z'), or from right to left (*> - from 'z' to 'a') on the left with automatic installation at the beginning of the next cycle of the link' ^'
on this element
6) The register of $S is defined as the adder based on calculations of each accepted train and its original value
is defined by the standard Sum parameter of function (0 - by default)
7) By default (in absence) formulas at existence or for lack of _If arguments function of $Sync actually in SA is implemented as:
<входной поток><входной поток>$Sync({,},_If(%~%,`*>!+=^%@%`))
Let's decrypt action of this primitive:
a) Owing to (2) at the beginning of processing of each train in the register '!' the empty layer is located ().
8) In the presence at value of the register '!' any (any) properties (% ~ %) the formula will organize in the scraper '*>' on elements
a, b... a train from left to right on function inputs) ALGOL language accomplishment of the transaction following it (+ =)
! := ! + <текущий элемент кортежа[ - ссылка '^' _Calc]>
According to river the 5th this transaction (+ =) fills up a layer '!' the next element (according to the link '^') a train, if necessary
brought to R-value (required property of % @ % to the right of the second operand' ^'). This property can specify also a part
the used element: atom (%. %) or layer (%, %) or both together (%., %).
Note: In this case as a result of processing of each train the layer from R-values of its elements forms
as their following - stream inputs of function less the defined _Scale (see further).
9) Completion of transactions of function of $Sync is defined by original value of the register'!' without properties (%%) and similar values of elements
train. Ahead of schedule this action with closing of all inputs of function (interruption of entrance flows) can be caused and by the transaction _End. At the same time
transactions of processing of actually absent train repeat and here can be transferred to an exit (the register'!') final,
perhaps, the corrected value of results in $S or calculated from $S, etc. registers
10) To similarly entrance and output flows automatically conducted counters of $i and $n - respectively, number arrived and accepted are entered
to processing of trains
11) As the only argument and in addition to the considered transactions the version of _Scale of a primitive of _If can be entered into structure of arguments
in shape (4-1) without "transaction", and as the only argument of function. Regardless of placement of this argument and transactions,
including _If, when receiving the next train in the beginning similarly (4-1) compliance of its elements to the corresponding conditions is checked
in _Scale. And only at compliance of these conditions from a train the elements listed in _Scale and counting of the elements which remained in a train are removed
begins again from left to right consistently as 'a', 'b', 'with'.... Thus a peculiar logical scale or the sinkhropotoki will be organized,
the selecting data are the trains for processing but which are directly not entering the processed trains.
Attention! After exhaustion of any entrance flow in the subsequent trains its element accepted by the last on is used
to requirements of _If and/or _Scale.
Note: _Scale and _If with the transactions _Go, _Skip and _Break can be used at synchronous processing of flows of expressions and data
function of $Eval (river 6)
4.3.2.1. Built-in macro definitions by setup of synchronous processing
Let's note in advance that - syntactically identical functions can enter into the macro definitions given here (in structure of their arguments)
additional exits, channels, conversion and processing input (item 4.2.1) and days off (item 4.2.3) of flows and even _Scale with additional entrance flows (sinkhropotok),
if of course _Scale is absent in macro definition implementation. At the same time these arguments (means) will be transferred in the same type
in the structure of the _Sync function developed together with transactions (1) in SA. Moreover it is possible to enter into them also operations with item 4.3.2 (1-9) which
in implementation of macro definition (SA) join in the end of a number of transactions which is already defined there. Therefore below these arguments fall:
$Trans( , )<[обрабатываемый ]поток><поток[ Свойств]>
In SA actually implements the following function:
<обрабатываемый поток><поток Свойств><=b%:%;.->$Sync(,,_If(%~%,`a!`))
If'!' NE contains the code of completion of transaction - there are any properties (% ~ %), transaction<= of the _Calc calculator brings
the train element a to a type determined by value (Properties </b>of %: %</b>) element b and result of reduction (register
'.') places (->) in the register! (function exit).
$Move( , ,)<поток R_значений><поток V-значений>
In SA actually implements the following function:
<поток R_значений><поток V-значений>$Sync(,, {_If(b:%&%,`a%@%=>b;b->!`),_Skip})
The argument of _If passes (_Skip) a train if the element 'b' of NE is V-value, differently transaction '=>' (item 5.3)
the _Calc calculator on this V-value makes the record R-values of an element 'a' of a train, if necessary giving it
to this R-value (property of % @ % to the right of' a'). The following transaction'-> 'places b (V-value)
in the register! (result of transaction)
$Copy( )<поток R-значений>
In SA actually is implemented by the following expression:
<поток R_значений>$Sync(,{_If(a:%\%,`a->!`,_Go),`!<-a%@%`})
_If argument in case of Atom - the element 'a' (% \%) places it in the register '!' (result of transaction) also completes (_Go) operations. Otherwise
transaction '<-' the element 'a' brought to R-value (% a @ %) - structure transaction (<-, р.5) копирует по всем уровням ее иерархии,
receiving the copy of the same structure in the Memory Blocks (MB) with unique links UKA and UKS on all hierarchy levels. UKA and UKS of a root of received
copies of structure are located in the register'!'.
$ToLay( , ,)<поток слоев><поток значений>
In SA is implemented as:
<поток слоев><поток значений>$Sync(,,_If(%~%,`a%&~.,%->!;!+=b%@%`))
Here each layer of R-value of element a of a train (a layer on UKS) is replenished (formula) with R-value of element b. In the beginning
(The 1st transaction->) in the register'!' places R-value of a layer with UKA=0 and not <>UKS0. For lack of a native layer it forms
automatic selection of free and empty BP. It is clear, that its R-value is determined by initial V-value a.
Following transaction '+=' layer '!' (a function exit) fills up with R-value b.
Example: $ToLay (*Num(3)) creates *Stream ("A" ("B") ", C" ("D")) at the exit flow of "A"("B",0), "C" ("D", 1.2)
$Sel( , ,)<поток слоев><поток индексов>
In SA is implemented as:
<поток слоев><поток индексов>$Sync(,, {_If(a:%,%,b:(%.9+~,%,%.|~,%),`a%&~.,%&b;.%&@%->!`,_Go),_Skip})
Transactions (formula and _Go) are executed only (_If) if the element 'a' has <>UKS0 (layer), and the element 'b' is the index whole
or name index. Otherwise the train is passed (_Skip). Transactions of a formula:
1) - element a and index b (the index - whole or index name) transaction 'also' creates V-value of UKS of a layer '.'.
2) V-value of the register'!' (an exit for the processed train) it is led to a type certainly having R-value if it
is absent: the layer on UKS R-values is replenished with enough indefinite elements (UKA=0, UKS =0)
Example: < R-значение[слоя(%~.,%)]>$Sel(*Sel(,Out:`!%@%->!`),0)
* Sel generates V-values of initial R-value of a layer (item 4.1.3) and transaction '->' at the main exit of Out * selects Sel for each it
V-value the R-value specified by it. At last, function of $Sel from UKS of these R-values and 0 creates 1 (0) a matrix column, perhaps, and
with indefinite elements if such are absent. Changing in expression 0 for 1, 2, etc., we will receive the 2nd, 3rd column, etc.
4.3.3. Asynchronous processing of flows
This processing is executed by the function of $Async transporting any element of a flow which arrived on its input on an exit (result). There is an opportunity
processings arriving to function (before transfer on an exit) the element, next from any its input, in addition entered transactions, and
it is almost identical to each of these entrance flows (item 4.2.1), including transactions with _If and formulas _Calc. The distinction consists only
in the following:
1) <операции>NE precedes the sequence of transactions (<операции>item 3.4.1.2 and item 4.2.1) a name of an entrance flow as imya_indeks: transactions _Go,
_Trans, _If, etc., including a number of transactions in brackets { } are direct function arguments of $Sync
2) As well as in case of an entrance flow the register '!' contains an element input, but now any flow and therefore is followed
additional property - a name of this flow (a-z)
3) The register of $S remains and kept by $Sync, uniform on all entrance flows of function, and initial is defined as the standard Sum parameter -
by default is the same 0
4) Registers of $n (number of already accepted and processed elements) and $e (the last from them) are kept on the arriving elements with all inputs
5) The property of % of *0% determines in general by the first the arrived element (by all inputs)
6) Upon termination of all entrance flows on "processing" the sign of end of a flow without properties arrives (%%). This sign can be
it is created actually by the transaction _End or _Break and processed by means (1)-(4), as well as other elements
7) Result of processing '!' arrives on a function exit if transactions (1) of NE block (_Skip, _End, _Break) this action.
4.3.3.1. Processing of structure flow of indexes. Indexing of structure
This processing is made by the macro definition which is built in FPM:
<структура><Поток индексов><глубина>$In([Struct:],[,Deep:])
$In processes a flow of indexes and on its basis creates an appropriate way (a flow of V-values of passable tops - nodes) on structure Struct from its root deep into on hierarchy with number of levels, NE of Deep exceeding a parameter value (26 by default), at the same time is possible automatically expands structure similar to the Perl language for matrixes. This macro definition in SA actually is implemented by function of $Async using the means of _Calc considered above:
<структура><Поток индексов><глубина>$Async(Struct:,,Deep:, _Par(Deep:{_If(%~.9+~,%,_Break),`26-!`,_if(%~.9+%,`26->!`),_If(%.90%,`!++`),_Break} Struct:`!%@%->Sum`), a:{_If(%%,_Break;),`Deep-$n;--`,_if(%.9~+%,_End);_If((%.9+%,%.9|%),_Go),_End)} `$S%~.,%&!;.%&@%->!;!%@%->$S`)
1) The primitive of _Par analyzes the Deep parameter: If it is not atom - positive whole, then work of function is interrupted (_Break).
Otherwise if its value exceeds 26, then it is accepted equal 26. At equality of Deep=0 it increases by 1 (! ++). Here (the second
_Par primitive argument) adduces Struct argument (the register '!') to R-value also defines it as the Sum parameter
2) After an argument of _Par transactions of processing of the next arriving index (an element of' a') follow from a flow: At the termination
(%%) a flow accomplishment of function is interrupted (_Break). Otherwise in case of achievement of $n (number of the accepted indexes from a flow) Deep values or
if the NE element accepted on an input by 'a' is whole (% of.9+ %) or a name index (%.9|%), the flow is interrupted and
the sign of the termination of a flow with otutstvuyushchy properties forms (%%) which is also processed considered here
transactions of processing of an element of' a'
Note: When giving on function (the register '!') an element without properties (%% - the end of a flow) action is similar to the transaction _End with that
difference that the considered transactions NOT will be restarted for this purpose "element"
3) The only transaction of processing is the formula _Calc - the last function argument of $Async:
- In the beginning from a layer (% ~., %) the adder (register) of $S (first with the initial Sum parameter in view of (1)) and the next index (the register '!')
flow of indexes transaction 'also' creates V-value in the register '.'.
- The following transaction '->' gives this V-value to certainly (UKS=0) specifying R-value (%&@%), if necessary opening
empty layer - BP with <>UKS0 and filling up a layer with necessary mimnimalny number of indefinite elements in absence in an element layer with
the specified index 'a' (now in V-value). The V-value specified (optional) is located in the register '!' - on
function exit
- The following transaction '->' places the R-value specified by V-value of an exit of function in the register of $S
Transactions (3) repeat the flow of indexes will not be exhausted yet or not interrupted with transactions (2) at its processing
4.3.4. Merge of flows
$Merge({ ,} )<поток><поток>
- function accepts in parallel on one element of each entrance incomplete flow. Having received all such elements (on one)
compares among themselves: minimum (and equal) on value elements of this set (train) as it should be (!) their receipts on one
sends to the exits, at the same time opening inputs from which they arrived for acceptance of the following elements on one. Then transaction
comparisons of elements of again formed train and sending minimum on an exit repeats.
Attention! It is clear, that in such transaction streamlining of each of entrance flows in ascending order of their values is supposed
elements. Let's remind (item 4.1.1) that the generator * Sel creates such flows and similar to $Merge executes streamlining of elements comparison
the atoms set (element) directly in a flow or on UKA R-values, perhaps, (specified) in turn defined
V-value. Comparison of atoms corresponds to transaction '=' the _Calc calculator (river 5) according to which number - atoms are compared them
values taking into account the sign (+ or-), lines and names lexicographic, etc.
Sel used by default by both functions * and $Merge transaction '=' comparisons of two elements and the choice "minimum" of them
(to be exact, preferable) it is possible to change by means of the same transactions _If (_if) and other, including formulas _Calc, considered earlier
when processing trains. In this case both of these functions (*Sel and $Merge) comparison of the next two elements (a layer or a train from elements
flows) transfer to transactions in the form of a train from elements' an 'and' b', it is possible also coincident. Problem of transactions: select one
from elements or both, as preferable as implementable each of functions (*Sel or $Merge) sortings. When choosing both these
two elements are considered as equal. Once again we will pay attention that each of functions * Sel and $Merge, implementing sorting transactions, respectively
layer and train (see above) repeatedly address the arguments entered below as their "transparent" to transactions
Features of the transactions _Calc in implementation of comparison of two elements (V-values of a layer of transaction * Sel) or on one of two any entrance flows
$Merge:
1) The _If form (4-1) in which (arguments) instead of names of entrance flows names 'a' and 'b' compared are used is allowed
elements
2) Register '!' in initial (before transactions) a status contains indefinite value (#) and its value by the end of accomplishment
transactions in any way NE affects their result
3) The register of $S by the beginning of function evaluations, as usual, accepts value of the standard Sum parameter of function (0 - by default) and saves
the value upon each transition from the next cycle of transactions (comparison of elements' an 'and' b') to the following.
4) Registers of $n are defined by number of already complete cycles of transactions of comparison of 'a' and 'b'.
5) The register of $l here NE forms and contains indefinite (#) value
6) The choice preferable ("minimum") among two 'a' and 'b' or both is made by installation of property '^'
formulas _Calc, for example, transaction a %^ % (b %^ %). In from lack of such choice, as well as when choosing both, both elements are considered as equal
regardless of their actual values.
4.4. FPM as adding machine
Let's remind that by default or by means of transactions of the _Calc calculator, in processing by function (item 4.3) and also at each its exit
a separate register of $S - Adder which contents, generally speaking, are any hierarchical structure defined is maintained
these transactions. Upon termination of processing (item 4.3) of initial data of function or a flow on any of function exits the value of $S complemented
property '!' (result) can be sent to the general with an output flow or a separate exit (item 4.2.3) where, using _Chanal (item 4.2.4),
organize its moving to a layer of a subspace (to save). However this procedure can be simplified, having included in the transactions _Calc one more:
_Sum( )<имя подпространства[п.2.6]>
The feature of this transaction consists that its accomplishment is postponed until completion of work of function (item 4.3) or an output flow
(item 4.2.3) and transaction consists that contents sootvenstvuyushchego (transactions of function or an output flow) the register of $S substitute value
the subspace specified by a name for lack of which this subspace is automatically created
Note: In case of function evaluation transactions the primitive of _Sum can be entered directly into structure of "transparent" function arguments instead of the introduction to structure of transactions offered above. It allows to use _Sum for the same purpose to quality of an argument built-in macro definitions (item 4.1.2.2, item 4.3.3.1) if, of course, implementation of which in SA conducts calculation of $S, for example:
* Num (5, _Sum(X)) generates 0, 1, 2, 3, 4
In this case the subspace of X will receive value of $S=0+1+2+3+4, t.e 10
4.5. Static and Dynamic properties of data members
1) Let's remind (river 2) that static member properties define:
a) The element relation to a flow (% [~] * %, % of *0%) or to provision in a train (% <Имя элемента>[^] %)
b) The code of an element - atom it is explicit value out of structure (% \%), V-(%&%, %&@%) or R-(% @ %) - value, indefinite value (%#%)
c) Existence and characteristics of atom (% [~]. [<тип>] %) set obviously or according to the link UKA in R-value
d) Existence and characteristics of a layer (% [~], <тип>%) according to the link UKS in R-value
In such order these elements in Properties atom together are also described or separately at determination of conditions of selection on required properties.
Thus, static properties are defined by specific physical characteristics which can be changed at an element, only
having changed its structure or representation in a flow or the register _Calc.
2) Along with static properties dynamic properties which can be changed without change of structure of an element and it are defined
relations to a flow or train. Actually here all characters, including special characters (<,=,>) and even the code of protection' enter<,=,>?' and
the code recommended in examples '!' (Result property), digit from 3 to 8 and also simola A-Z latin alphabets. Value of these
properties is defined by the user and they defined for an element in random order are considered as a set from not
the repeating codes (characters), specified separately or together with (1a) - (1b) and in the latter case are specified in Properties atom earlier,
and in any order. As well as the code '~', in the same way denying can precede any dynamic static property
existence of this property at selection of an element in a flow or a train. However now without change of physical characteristics of an element it is possible for it
appropriate one or more dynamic properties or delete them if, of course, they are there:
Examples in formulas: 1) '! %! %' - contents the register '!' is replenished with property '!', if earlier it is absent there 2) '! %!.~, %;->!' - it is similar (1) and in addition from K-value '!' the layer if it is <>(UKS0) there is removed<> 3) '! % ~! %' -at register contents '!' the property is removed '!', if earlier it was there
Directly at operands of the transactions _Calc, except '.', it is possible to change dynamic properties only in absence
near it static properties - examples (1) and (3). Otherwise the result of reduction of an operand to required properties is located
in the register'.'. Moreover, dynamic properties by method (1) and (3) can be entered and changed even at the operands allowing NE
changes of their structure and static properties</b>
Attention! The exception makes property '?' protection of atom or a layer, installed separately for each of them and placed on the right
from atom determination (%.? %) and/or layer (%? %)
Note! In the given examples (1)-(3) the first (perhaps, only) transaction consists of one operand (there is no activity code) and
only in case of (2) it causes transaction of the premises of its result in the register '.'. In the presence of an activity code its operands can
be followed on the right by properties to which the operand should be previously brought previously. In this case an operand
physically NE is given to this property, and only its temporary copy prepares (similar to the register '.'), answering to these
to properties.
Dynamic properties, equally and at the same time used with static significantly expand possibilities of distribution of created
function of elements on its exits, and regarding logic of calculations (transactions) of function and processing by the transactions _Calc input and output
flows.
Application 1. The used reductions:
FPM -Functional Stream Mashina p. 4 -Section 4 of the FPM project item 2.3 -point 3 of Section 2 SA -Structure Aktivatsy – implementing expression of language (superposition functions) collective of appropriately connected micro computers, each of which implements separate function or the calculator _Calc DRP -dynamically distributed memory over which funkutsionirut micro EVM SA BP -the DRP block selected under atom or a layer of structure UKA -pointer (link to BP) of atom (item 2.3) UKS -pointer (link to BP) of a layer (river 2)