(@ +-
    (say "\t\t\t\t" 'Total'
         "\t\t"     'Last Month' "\n")
    (.* report row >
        (say title "\t\t\t" total 
                   "\t\t" last-month -
             (row.report.competition-index.title .title) |
             (row.report.competition-index.total # '0.00' -> .total) |
             (row.report.competition-index.last-month # '0.00' -> .last-month)
        ) 
    -
        (# read .salaries
         # process salaries .report)
    )
)

(@ process salaries .report +-
    (@ report-item-from title item +-
        (![= 0] item.vacancies.total >
            (% -salary-report >
                title                                                   .report.competition-index.title
                ((/ item.vacancies.total) item.resumes-total)           .report.competition-index.total
                ((/ item.vacancies.last-month) item.resumes-last-month) .report.competition-index.last-month
            )
        >
            (% -salary-report >
                title                                                   .report.competition-index.title
                ((/ item.vacancies.last-month) item.resumes-last-month) .report.competition-index.total
                ((/ item.vacancies.last-month) item.resumes-last-month) .report.competition-index.last-month
            )
        )
    )

    (# records-in salaries (@ job-title salary-item +- 
                               (attach report (# report-item-from job-title salary-item))
                           )
    )
+
    {list : string <- salary} salaries
    {list : string <- salary-report} report
)

(@ read .salaries +-
    (^ 
        ''                        (% + vacancies.total vacancies.last-month resumes.total resumes.last-month )
        'Программист'             (%             37688                 5841        416208             363771 )
        'Программист 1С'          (%              4293                  846        140367             113422 )
        'Программист Web'         (%              2174                  348         97281              84908 )
        'Программист PHP'         (%              1779                  489         42034              35338 )
        'Программист C++'         (%               681                  108         35313              21743 )
        'Программист Delphi'      (%               127                   48         39332              22949 )
        'Программист Java'        (%              1245                  474         34142              25179 )
        'Программист C#'          (%               697                  341         25906              20744 )
        'Программист SQL'         (%               335                  148         73193              68230 )
        'Программист JavaScript'  (%               719                  282         37453              32372 )
        'Программист Python'      (%               556                  211         15780              13260 )
        'Программист Ruby'        (%               164                   45          2376               2270 )
        'Агент'                   (%              5328                  405        306179             159430 )
        'Юрист'                   (%              8419                 1568        968479             399608 )
        'Бухгалтер'               (%             54017                 3433       2371355             958053 )
        'Аналитик'                (%              5261                 2969        394656             371047 )
        'Маркетолог'              (%              6786                 1164        191428             162237 )
        'Администратор'           (%             62175                 3238       1880289             809838 )
        'Инженер'                 (%             85284                 5993       2730572            1191587 )
        'Менеджер'                (%            522871                22389       5156307            2578817 )
        '2018'                    (%                                 646949                         34572790 )
    >
        .salaries
    )
+
    {list : string <- salary} salaries
)

(% salary +-
    (% 
        {integer} total
        {integer} last-month
    ) vacancies
    (% 
        {integer} total
        {integer} last-month
    ) resumes
)

(% salary-report +-
    {string} title
    (% 
        {float} total
        {float} last-month
    ) competition-index
)
