Packages
cldr_utils
2.19.2
2.29.7
2.29.6
2.29.5
2.29.4
2.29.3
2.29.2
2.29.1
2.29.0
2.28.3
2.28.2
2.28.1
2.28.0
2.27.0
2.26.0
2.25.0
2.24.2
2.24.1
2.24.0
2.23.1
2.23.0
2.22.0
2.21.0
2.20.0
2.19.2
2.19.1
2.19.0
2.18.0
2.17.2
2.17.1
2.17.0
2.17.0-rc.0
2.16.0
2.15.1
2.15.0
2.14.1
2.14.0
2.13.3
retired
2.13.2
2.13.1
2.13.0
retired
2.12.0
2.11.0
2.10.0
2.9.1
2.9.0
retired
2.8.0
2.7.0
2.6.0
2.5.0
2.4.0
2.3.0
2.2.0
2.1.0
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
Map, Calendar, Digits, Decimal, HTTP, Macro, Math, and String helpers for ex_cldr.
Current section
Files
Jump to
Current section
Files
lib/cldr/utils/enum.ex
defmodule Cldr.Enum do
@doc """
Very simple reduce that passes both the head and the tail
to the reducing function so it has some lookahead.
"""
def reduce_peeking(_list, {:halt, acc}, _fun),
do: {:halted, acc}
def reduce_peeking(list, {:suspend, acc}, fun),
do: {:suspended, acc, &reduce_peeking(list, &1, fun)}
def reduce_peeking([], {:cont, acc}, _fun),
do: {:done, acc}
def reduce_peeking([head | tail], {:cont, acc}, fun),
do: reduce_peeking(tail, fun.(head, tail, acc), fun)
def reduce_peeking(list, acc, fun),
do: reduce_peeking(list, {:cont, acc}, fun) |> elem(1)
def combine_list([head]),
do: [to_string(head)]
def combine_list([head | [next | tail]]),
do: [to_string(head) | combine_list(["#{head}_#{next}" | tail])]
end