[Solved] Spanning repeatable keys

In Elixir it’s quite easy with Enum.group_by/3: iex> Enum.group_by(values, fn {key, _} -> key end, fn {_, value} -> value end) %{ “Caerus1” => [“Ramses Refiner”, “Jupiter Refiner”, “Jupiter Other”, “Trader 13”, “Cathode Supplier 4”], “Dionysus3” => [“Cathode Supplier 4”, “Ramses Refiner”, “Trader 13”, “Jupiter Refiner”, “Jupiter Other”], “Prometheus2” => [“Jupiter Other”, “Ramses Refiner”, “Trader … Read more

[Solved] Why does the absence of an else block translate to Unit type return for a function?

I can correct this by adding the else clause, but how come if there is no outcome handled by default, the function tries to return a Unit? In Scala, unlike more “imperative” languages, (almost) everything is an expression (there are very few statements), and every expression evaluates to a value (which also means that every … Read more

[Solved] What would be the best way to sort events according to its date

First you need to convert it to an array: var events = Object.keys(obj).map((key) => { return Object.assign({}, obj[key], {eventName: key}); }); Then you need to group them by date. We can do this with lodash. var groupBy = require(‘lodash/collection/groupBy’); var eventsWithDay = events.map((event) => { return Object.assign({}, event, {day: new Date(event.date).setHours(0, 0, 0, 0)) }); … Read more