Where to find chunks in haskell? -


i'm trying follow tutorial: https://wiki.haskell.org/tutorials/programming_haskell/string_io.

in last part 7 extension: using smp parallelism copy code fails compile error message

/home/dhilst/parallelspell.hs:13:20: error:     variable not in scope: chunk :: int -> [string] -> t 

i searched chunks @ hoogle , got data.text.internal.lazy, seems internal module. , couldn't import anyway.

here code:

import data.set hiding (map) import data.maybe import data.char import text.printf import system.io import system.environment import control.concurrent import control.monad  main =         (f,g,n) <- readfiles         let dict = fromlist (lines f)             work = chunk n (words g)         run n dict work  run n dict work =         chan <- newchan         errs <- getchancontents chan         mapm_ (forkio . thread chan dict) (zip [1..n] work)         wait n errs 0   wait n xs = when (i < n) $ case xs of         nothing : ys -> wait n ys $! i+1         s  : ys -> putstrln s >> wait n ys  thread chan dict (me,xs) =         mapm_ spellit xs         writechan chan nothing         spellit w = when (spell dict w) $                 writechan chan . $ printf "thread %d: %-25s" (me::int) w  spell d w = w `notmember` d  readfiles =         [s,n] <- getargs         f <- readfile "/usr/share/dict/words"         g <- readfile s         return (f,g, read n) 

and here compilation line:

ghc -o --make -threaded parallelspell.hs 

-- update: write own version of chunk based on quest:how partition list in haskell?

chunk :: int -> [a] -> [[a]] chunk _ [] = [] chunk n xs = (take n xs) : (chunk n (drop n xs)) 

still, means tutorial i'm following old , out of date!? can confirm if function existed day or if i'm missing something?

regards,

looks tutorial forgot define chunk. encourage update wiki include suitable definition.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -