{-# LANGUAGE OverloadedStrings #-}
import Data.List
data Kompanija = Kompanija {departamenti :: [Departament]}
data Departament
= Departament
{imja
:: String, rabi
:: [Rabo4ij
]} data Rabo4ij = Rabo4ij {dengi :: Dengi, kofe :: Kofe, stranici :: Stranici, rang :: Rang, ktoPoZhizni :: KtoPoZhizni}
data KtoPoZhizni = Rab | Rukovoditelj
data Rang
= Pervij
| Vtoroj
| Tretij
deriving Enum
vektor = Kompanija [
Departament "Zakupki" $ join [ 9 `x` "me1", 3 `x` "me2", 2 `x` "me3", 2 `x` "ma1", ["me2R"]],
Departament "Prodazhi" $ join [12 `x` "me1", 16 `x` "ma1", 3 `x` "an1", 2 `x` "an2", ["ma2R"]],
Departament "Reklama" $ join [15 `x` "ma1", 10 `x` "ma2", 8 `x` "me1", 2 `x` "in1", ["ma3R"]],
Departament "Logistika" $ join [13 `x` "me1", 5 `x` "me2", 5 `x` "in1", ["me1R"]]]
dela = [
poschitat rabov,
poschitat dengi,
poschitat kofe,
poschitat stranici,
\departamenta -> poschitat dengi departamenta/poschitat stranici departamenta ]
main
= mapM_ print $ transpose
$ vicheslit dela vektor
vicheslit cho kompanija
= [map f
(departamenti kompanija
) | f
<- cho
]
poschitat cho gde
= sum $ map cho
$ rabi gde
menedzher = Rabo4ij 500 20 200
marketolog = Rabo4ij 400 15 150
inzhener = Rabo4ij 200 5 50
analitik = Rabo4ij 800 50 5
x = replicate
imena
= map imja
(departamenti vektor
)
instance IsString Rabo4ij where
fromString (c1:c2:r:kto) = rabo4ij where
rabo4ij = case ktoPoZhizni of
Rukovoditelj -> rab {dengi = 1.5*dengi rab, kofe = 2*kofe rab, stranici = 0}
_ -> rab
ktoPoZhizni = case kto of
['R'] -> Rukovoditelj
[] -> Rab
govno
-> error $ "ploxoj ktoPoZHizni: " ++ govno
rang
= toEnum (digitToInt r
- 1)
defaultRab = (case [c1,c2] of
"me" -> menedzher
"ma" -> marketolog
"in" -> inzhener
"an" -> analitik
govno
-> error $ "ploxaja abbreviat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IGNhc2Uga3RvUG9aaGl6bmkgb2YKICAgICAgICAgICAgUnVrb3ZvZGl0ZWxqIC0+IHJhYiB7ZGVuZ2kgPSAxLjUqZGVuZ2kgcmFiLCBrb2ZlID0gMiprb2ZlIHJhYiwgc3RyYW5pY2kgPSAwfQogICAgICAgICAgICBfIC0+IHJhYgogICAgICAgIAogICAgICAgIGt0b1BvWmhpem5pID0gY2FzZSBrdG8gb2YKICAgICAgICAgICAgWydSJ10gLT4gUnVrb3ZvZGl0ZWxqCiAgICAgICAgICAgIFtdICAgIC0+IFJhYgogICAgICAgICAgICBnb3ZubyAtPiBlcnJvciAkICJwbG94b2oga3RvUG9aSGl6bmk6ICIgKysgZ292bm8KICAgICAgICAgICAgCiAgICAgICAgcmFuZyA9IHRvRW51bSAoZGlnaXRUb0ludCByIC0gMSkgCiAgICAgICAgICAgIAogICAgICAgIHJhYiA9IGRlZmF1bHRSYWIge2RlbmdpID0gZGVuZ2kgZGVmYXVsdFJhYiAqICgxKzAuMjUqZnJvbUludGVncmFsIChmcm9tRW51bSByYW5nKSl9IHdoZXJlCiAgICAgICAgICAgIGRlZmF1bHRSYWIgPSAoY2FzZSBbYzEsYzJdIG9mCiAgICAgICAgICAgICAgICAibWUiIC0+IG1lbmVkemhlcgogICAgICAgICAgICAgICAgIm1hIiAtPiBtYXJrZXRvbG9nCiAgICAgICAgICAgICAgICAiaW4iIC0+IGluemhlbmVyCiAgICAgICAgICAgICAgICAiYW4iIC0+IGFuYWxpdGlrCiAgICAgICAgICAgICAgICBnb3ZubyAtPiBlcnJvciAkICJwbG94YWphIGFiYnJldmlhdHVyYSByYWJhOiAiICsrIGdvdm5vKSByYW5nIGt0b1BvWmhpem5p
[17.0,9612.5,350.0,3100.0,3.100806451612903]
[34.0,17550.0,760.0,4825.0,3.6373056994818653]
[36.0,16300.0,575.0,5450.0,2.9908256880733943]
[24.0,11375.0,425.0,3850.0,2.9545454545454546]