Law of cosines - triples: Difference between revisions
Content added Content deleted
Line 265: | Line 265: | ||
-> [(Int, Int, Int)] |
-> [(Int, Int, Int)] |
||
triangles f n = |
triangles f n = |
||
let mapRoots |
let mapRoots = Map.fromList $ ((,) =<< (^ 2)) <$> [1 .. n] |
||
mapRoots = Map.fromList $ ((,) =<< (^ 2)) <$> [1 .. n] |
|||
in Set.elems $ |
in Set.elems $ |
||
foldr |
foldr |
||
Line 273: | Line 272: | ||
Just c -> Set.insert (a, b, c) triSet |
Just c -> Set.insert (a, b, c) triSet |
||
_ -> triSet)) |
_ -> triSet)) |
||
(Set.fromList [] |
(Set.fromList []) |
||
([1 .. n] >>= |
([1 .. n] >>= |
||
(\a -> (flip (,,) a =<< (a * a +) . (>>= id) (*)) <$> [1 .. a])) |
(\a -> (flip (,,) a =<< (a * a +) . (>>= id) (*)) <$> [1 .. a])) |
||
-- TESTS --------------------------------------------------------------------- |
-- TESTS ------------------------------------------------------------------------ |
||
f90, f60, f60ne, f120 :: Map.Map Int Int -> Int -> Int -> Int -> Int -> Maybe Int |
f90, f60, f60ne, f120 :: Map.Map Int Int -> Int -> Int -> Int -> Int -> Maybe Int |
||
f90 dct x2 ab a b = Map.lookup x2 dct |
f90 dct x2 ab a b = Map.lookup x2 dct |