-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add leap exercise * Remove template type sig We don't provide these in the Elm track, so it seems sensible not to do it here either.
- Loading branch information
Showing
7 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
module HelloWorld where | ||
|
||
import Prelude | ||
import Data.Maybe (Maybe(Just, Nothing)) | ||
|
||
helloWorld :: Maybe String -> String |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "leap", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"output" | ||
], | ||
"dependencies": { | ||
"purescript-prelude": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"purescript-psci-support": "^2.0.0", | ||
"purescript-test-unit": "^10.0.1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Leap where | ||
|
||
import Prelude | ||
|
||
isLeapYear :: Int -> Boolean | ||
isLeapYear year = | ||
mod year 4 == 0 && | ||
mod year 100 /= 0 || | ||
mod year 400 == 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module Leap where |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Test.Main where | ||
|
||
import Prelude | ||
import Test.Unit (suite, test) | ||
import Test.Unit.Main (runTest) | ||
import Test.Unit.Assert as Assert | ||
import Leap as Leap | ||
|
||
|
||
main = runTest do | ||
suite "Leap.isLeapYear" do | ||
test "leap year" do | ||
Assert.equal true $ Leap.isLeapYear 1996 | ||
test "non-leap year" do | ||
Assert.equal false $ Leap.isLeapYear 1997 | ||
test "non-leap even year" do | ||
Assert.equal false $ Leap.isLeapYear 1998 | ||
test "century" do | ||
Assert.equal false $ Leap.isLeapYear 1900 | ||
test "second century" do | ||
Assert.equal false $ Leap.isLeapYear 1800 | ||
test "fourth century" do | ||
Assert.equal true $ Leap.isLeapYear 2400 | ||
test "y2k" do | ||
Assert.equal true $ Leap.isLeapYear 2000 |