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