Collect and sort square numbers in ascending order from three lists: Difference between revisions

m
No edit summary
Line 276:
 
isPerfectSquare :: Integral a => a -> Bool
isPerfectSquare n= (==) <*> ((^ 2) . floor . sqrt . fromIntegral)
 
let sqr = (floor . sqrt) (fromIntegral n :: Double)
in n == sqr ^ 2
 
--------------------------- TEST -------------------------
Line 284 ⟶ 283:
main =
print $
squaresSorted
[ [3, 4, 34, 25, 9, 12, 36, 56, 36],
, [2, 8, 81, 169, 34, 55, 76, 49, 7],
, [75, 121, 75, 144, 35, 16, 46, 35]
]</syntaxhighlight>
{{Out}}
<pre>[4,9,16,25,36,36,49,81,121,144,169]</pre>
9,659

edits