Credo: ExSlop's join separator and length guard

69c87f3 · Gabe Morell · 2026-11-04 21:24

6 files +5 -5

Files changed

modified lib/lambent_ex/machine.ex
+2 −2
@@ -263,12 +263,12 @@ defmodule LambentEx.Machine do
263 263
264 264 defp id(state) do
265 265 step = state[:step] |> stripstep
266 − [step, "x", state[:name]] |> Enum.join("")
266 + [step, "x", state[:name]] |> Enum.join()
267 267 end
268 268
269 269 defp id(state, key) do
270 270 step = state[:step] |> stripstep
271 − [step, "x", state[:name], "x", key] |> Enum.join("")
271 + [step, "x", state[:name], "x", key] |> Enum.join()
272 272 end
273 273
274 274 defp publish(state) do
modified lib/lambent_ex/machine/steps/breathe.ex
+3 −3
@@ -228,9 +228,7 @@ defmodule LambentEx.Machine.Steps.Breathe do
228 228 are enough. Gaps are folded against the typical one, so a missed beat
229 229 counts as two beats rather than halving the tempo.
230 230 """
231 − def estimate(onsets) when length(onsets) < 4, do: nil
232 −
233 − def estimate(onsets) do
231 + def estimate([_, _, _, _ | _] = onsets) do
234 232 gaps =
235 233 onsets
236 234 |> Enum.chunk_every(2, 1, :discard)
@@ -254,6 +252,8 @@ defmodule LambentEx.Machine.Steps.Breathe do
254 252 end
255 253 end
256 254
255 + def estimate(_onsets), do: nil
256 +
257 257 defp median(list) do
258 258 sorted = Enum.sort(list)
259 259 Enum.at(sorted, div(length(sorted), 2))

Parents: 142495f