Sha256: a067e17c0b20c36d0e5a1dd053fcf59bb132139bf3d1368442e61cf7491a9500
Contents?: true
Size: 329 Bytes
Versions: 238
Compression:
Stored size: 329 Bytes
Contents
defmodule Grains do use Bitwise, only_operators: true def square(number) when number in (1..64), do: { :ok, 1 <<< (number - 1) } def square(_), do: { :error, "The requested square must be between 1 and 64 (inclusive)" } def total, do: { :ok, Enum.reduce(1..64, 0, fn(n, acc) -> {:ok, sq} = square(n); acc + sq end) } end
Version data entries
238 entries across 238 versions & 1 rubygems