2024-03-11 10:34:40 +01:00
|
|
|
# Lösung: Map und Reduce: Gewinnermittlung für die Abzock GmbH
|
2024-03-11 10:32:49 +01:00
|
|
|
|
2024-03-11 10:39:04 +01:00
|
|
|
|
|
|
|
```$2#!/usr/bin/env -S clojure -M
|
|
|
|
|
|
|
|
(def verkaeufe-stueckzahlen {
|
|
|
|
:PS5 [ 10, 5, 8, 13, 22, 42, 110 ],
|
|
|
|
:GTX1090 [ 5, 7, 11, 54, 90 ],
|
|
|
|
:OEL [ 10, 44, 100, 343, 66, 52, 23 ]})
|
|
|
|
|
|
|
|
(def verkaufspreise {
|
|
|
|
:PS5 1239,
|
|
|
|
:GTX1090 1699,
|
|
|
|
:OEL 9 })
|
|
|
|
|
|
|
|
(println "Gewinnermittlung Abzock GmbH")
|
|
|
|
|
|
|
|
(defn summiere [stueckzahlen preise]
|
|
|
|
(doseq [[key values] stueckzahlen]
|
|
|
|
(println key
|
|
|
|
(reduce + (map #(* % (key preise)) values))
|
|
|
|
"EUR")))
|
|
|
|
|
|
|
|
(summiere verkaeufe-stueckzahlen verkaufspreise)
|
|
|
|
|
|
|
|
```
|