Last active
December 12, 2015 00:28
-
-
Save ooharak/4683407 to your computer and use it in GitHub Desktop.
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
module Triplet | |
where | |
import List | |
newtype Triplet = Triplet Int | |
deriving(Show,Read) | |
instance Eq Triplet where | |
Triplet i == Triplet j = i == j | |
instance Ord Triplet where | |
(Triplet i) `compare` (Triplet j) | |
| (triplet i) < (triplet j) = LT | |
| (triplet i) > (triplet j) = GT | |
| otherwise = compare i j | |
where triplet x = (x `mod` 3) | |
test = List.sortBy compare [Triplet x|x<-[3,1,2,6,7,8,9]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment