• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão60c48182945a24d2f95e9bdff42cdabd01ad6010 (tree)
Hora2010-10-13 07:23:50
Autorlorenzo
Commiterlorenzo

Mensagem de Log

Apart from some minor modifications, I am now properly iterating a function
on a list of file following the suggestions by Daniel. Now I avoid generating
(though in a lazy way) a list with the contents of each file since that means
opening all those files and I can run short of handles.

Mudança Sumário

Diff

diff -r 92918f99cb83 -r 60c48182945a haskell/read_sequential.hs
--- a/haskell/read_sequential.hs Tue Oct 12 10:38:04 2010 +0000
+++ b/haskell/read_sequential.hs Tue Oct 12 22:23:50 2010 +0000
@@ -17,37 +17,35 @@
1717
1818 -- Uncomment the bit above if you want to read the list of files from a file
1919
20- let nums=[1..260]
20+ let nums=[1..2]
2121
2222
23- fl <- getAllLengths nums
24-
25- -- putStrLn "fl is, "
26- -- print fl
27-
28- cl <- file_conv_all nums
29-
30- -- putStrLn "cl is, "
31- -- print cl
3223
33- -- putStrLn "len cl is, "
34- -- print (length cl)
3524
36- -- putStrLn "len cl!!1 is, "
37- -- print (length $ cl!!1)
25+ -- cl <- file_conv_all nums
26+
3827
39- let entr_all= map entropy_list cl
28+ -- let entr_all= map entropy_list cl
4029
41- -- putStrLn "entr_all is, "
42- -- print (entr_all)
30+ -- save_vector "entropy.dat" entr_all
31+
32+-- NB: the 3 lines above (which are now comments) calculate correctly the entropy
33+-- but they have the problem if using too many file handles. The procedure I
34+-- follow below is really the correct one.
35+
36+
37+ my_entropy <- get_all_entropies nums
4338
44- save_vector "entropy.dat" entr_all
45-
39+ save_vector "entropy.dat" my_entropy
40+
41+
4642 putStrLn "So far so good "
4743
4844
45+ -- #########################################################
46+
4947 filename :: Int -> FilePath
50-filename i = "time_series_" ++ show i ++ "_.dat"
48+filename i = "file" ++ show i ++ ".dat"
5149
5250 fileLength :: FilePath -> IO Int
5351 fileLength file = fmap length (readFile file)
@@ -55,21 +53,30 @@
5553 getAllLengths :: [Int] -> IO [Int]
5654 getAllLengths nums = mapM (fileLength . filename) nums
5755
56+ -- #########################################################
57+
58+-- the 3 functions above are examples by Daniel to calculate the lengths of multiple files
59+-- and they are a kind of template: the whole point is to replace fileLength with my own function
60+-- and getAllLengths with the iteration of my own function.
61+
62+
63+entropy_on_file file = fmap entropy_list (conv_to_list file)
64+
65+-- entropy_on_file is along the lines of fileLength by Daniel, just I need to be careful when
66+-- reading something (a string NOT consisting only of numbers [there are also letters]) into a list
67+-- (I now need to use conv_to_list instead of readFile).
68+
69+
70+get_all_entropies nums = mapM (entropy_on_file . filename) nums
71+
72+-- get_all_entropies is precisely along the lines of getAllLengths by Daniel and it iterates
73+-- entropy_on_file on my file list.
74+
5875
5976 conv_to_list file = fmap lines ( (readFile file))
6077
6178 file_conv_all nums = mapM (conv_to_list . filename) nums
6279
63--- entropy_calc_all nums = mapM (entropy_list .file_conv_all) nums
64-
65-
66--- getAllentr :: [Int] -> IO [Int]
67--- getAllentr nums = mapM (fileLength . filename) nums
68-
69-
70-
71-
72-
7380 is_sublist sublist list = sublist `isInfixOf` list
7481
7582