Law of cosines - triples: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: (minor tidying)) |
(→{{header|Haskell}}: corrected label order, updated type signature) |
||
Line 262: | Line 262: | ||
import Control.Arrow (second) |
import Control.Arrow (second) |
||
triplesFound :: Int -> [(Int, [Int])] |
|||
triplesFound n = |
triplesFound n = |
||
let xs = ((,) <*> (^ 2)) <$> [1 .. n] :: [(Int, Int)] |
let xs = ((,) <*> (^ 2)) <$> [1 .. n] :: [(Int, Int)] |
||
Line 287: | Line 287: | ||
show (length g) <> " solutions for " <> s <> " degrees:\n" <> show g <> |
show (length g) <> " solutions for " <> s <> " degrees:\n" <> show g <> |
||
"\n") |
"\n") |
||
[" |
["120", "90", "60"] $ |
||
(nub . fmap snd) <$> |
(nub . fmap snd) <$> |
||
groupBy (on (==) fst) (sortBy (comparing fst) (fmap (fmap sort) xs)) |
groupBy (on (==) fst) (sortBy (comparing fst) (fmap (fmap sort) xs)) |