ListUtil.hs
{-# LANGUAGE TransformListComp #-} squareReverse :: [Integer] -> [Integer] squareReverse list = [x^2 | x <- list, then reverse]
Prelude> :load ListUtil.hs [1 of 1] Compiling Main ( ListUtil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> squareReverse [1, -2, 8, -6] [36,64,4,1]
No comments:
Post a Comment