diff options
Diffstat (limited to 'testsuite/tests/dph/words/Main.hs')
-rw-r--r-- | testsuite/tests/dph/words/Main.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/tests/dph/words/Main.hs b/testsuite/tests/dph/words/Main.hs new file mode 100644 index 0000000000..bc706fb751 --- /dev/null +++ b/testsuite/tests/dph/words/Main.hs @@ -0,0 +1,37 @@ + +import WordsVect +import Data.Array.Parallel.Prelude +import qualified Data.Array.Parallel.Prelude.Word8 as W +import qualified Data.Array.Parallel.PArray as P +import qualified Data.Array.Parallel.Unlifted as U +import Data.Char + +main + = do -- take the filename containing the words as the first arg + let str = "When I look into the looking glass I'm always sure to see" + ++ " no matter how I dodge about, me looking back at me." + + -- convert string to a PArray + let paStr :: PArray W.Word8 + paStr = fromUArrPA' $ U.map W.fromInt $ U.fromList $ map ord str + + + -- break the string into words then flatten it back + let str' :: String + str' = map chr + $ map fromIntegral + $ P.toList + $ wordsOfPArray paStr + + + -- count the number of words in the string, using the vectorised program + let wordCountVect = fromIntegral $ wordCountOfPArray paStr + + -- count the number of words with the ye'olde list way + let wordCountList = length $ words str + + -- + putStr $ show str' ++ "\n" + ++ "word count vect = " ++ show wordCountVect ++ "\n" + ++ "word count lists = " ++ show wordCountList ++ "\n" +
\ No newline at end of file |