Skip to content

Instantly share code, notes, and snippets.

@ooharak
Last active December 12, 2015 00:28
Show Gist options
  • Save ooharak/4683407 to your computer and use it in GitHub Desktop.
Save ooharak/4683407 to your computer and use it in GitHub Desktop.
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