AR
а кстати, мб описаный кейс и решит
Size: a a a
AR
AR
AR
AR
selector = fn f ->
fn _, data, next ->
data |> Enum.filter(f) |> Enum.map(next)
end
end
data = %{items: [%{id: 2, count: 2}, %{id: 1, count: 3}, %{id: 2, count: 4}]}
get_in(data, [:items, selector.(&(1 == &1[:id])), :count])
AR
AD
AR
AR
AR
AR
(->>
{:items [{:id 2 :count 2}
{:id 1 :count 3}
{:id 1 :count 4}]}
(sp/transform [:items (sp/filterer #(= 1 (:id %))) sp/FIRST :count] inc))
{:items [{:id 2, :count 2} {:id 1, :count 4} {:id 1, :count 4}]}
AB
composed_path = path1 ~> path2
AD
AD
%{data | items: Map.new(data[:items], &{&1.id, &1})}
AD
data[:items][1]
AR
AB
AD
AR
AR
AD