Skip to content

Instantly share code, notes, and snippets.

@shoz-f
Created October 1, 2018 12:12
Show Gist options
  • Select an option

  • Save shoz-f/cd20a5627cb42dd60418c5a295ddd0b9 to your computer and use it in GitHub Desktop.

Select an option

Save shoz-f/cd20a5627cb42dd60418c5a295ddd0b9 to your computer and use it in GitHub Desktop.
基本のコード(純関数型)
defmodule StopwatchA do
import System, only: [ monotonic_time: 1 ]
def activate() do
now = monotonic_time(100)
{0, now}
end
def restart(last_time) do
now = monotonic_time(100)
{now - last_time, now}
end
def lap(last_time) do
now = monotonic_time(100)
{now - last_time, last_time}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment