Created
October 1, 2018 12:12
-
-
Save shoz-f/cd20a5627cb42dd60418c5a295ddd0b9 to your computer and use it in GitHub Desktop.
基本のコード(純関数型)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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