Distinct power numbers: Difference between revisions
Content added Content deleted
Line 378: | Line 378: | ||
(\xs -> [x ^ y | x <- xs, y <- xs]) [2 .. 5]</lang> |
(\xs -> [x ^ y | x <- xs, y <- xs]) [2 .. 5]</lang> |
||
or |
or liftA2 expression: |
||
<lang haskell>import |
<lang haskell>import Control.Applicative (liftA2) |
||
import Control.Monad (join) |
|||
import qualified Data.Set as S |
|||
main :: IO () |
main :: IO () |
||
main = |
main = |
||
(print . S.elems . S.fromList) $ |
(print . S.elems . S.fromList) $ |
||
join |
|||
(\xs -> xs >>= (<$> xs) . (^)) |
|||
(liftA2 (^)) |
|||
[2 .. 5]</lang> |
[2 .. 5]</lang> |
||
{{Out}} |
{{Out}} |