99,343 views
7 votes
7 votes
write a haskell function whose content is a list comprehension that returns a list of lists. the return list is a full list of all pythagorean triples than consists entirely of integers between 1 and 15. it is ok that the ghci will convert the ints to doubles. the list should not contain duplicates (ie, if it contains [3.0, 4.0, 5.0] it should not also contain [4.0, 3.0, 5.0]) put all the necessary code in the window, including code you wrote in the ungraded exercise if you reuse it here. show your output as well. hint:

User Hpavc
by
2.7k points

1 Answer

11 votes
11 votes

import Data.List (nub)

func::[(Double, Double, Double)]

func =

[(a, b, c) | a <- [1..15], b <- [1..15], c <- [1..15], a^2 + b^2 == c^2]

|> nub

main :: IO ()

main = print func

User Philip Murphy
by
2.6k points