• R/O
  • SSH

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Révision806452ca6e75ac7d61e76e16f36af28a0e928dcb (tree)
l'heure2010-10-12 00:00:13
Auteurlorenzo
Commiterlorenzo

Message de Log

I am developing this code which calculates the entropy of a time series, but
I still need to learn how to iterate it on a set of files.

Change Summary

Modification

diff -r b6e440db2e0d -r 806452ca6e75 haskell/string-match.hs
--- a/haskell/string-match.hs Mon Oct 11 10:43:25 2010 +0000
+++ b/haskell/string-match.hs Mon Oct 11 15:00:13 2010 +0000
@@ -7,67 +7,31 @@
77
88 main = do
99
10-
11- -- let list = [4,55,66,77,88,99,12,9,77,88,99,12,-99]
12- let list = [999,99,9]
13-
14- -- let list = ["a","b","c","c"]
15-
16-
17- -- let sub_list = [66,77,88]
18-
19- -- let i = 9
20-
21- -- let j =2
22-
10+ -- let file_list = [1,2,3]
2311
2412
25- -- let b = iter_find list i
26-
27- -- putStrLn "b is, "
28- -- print b
29-
30-
31- -- let b = iter_find_efficient list i
3213
33- -- putStrLn "the list of True is, "
34- -- print b
35-
36- -- let b = count_string_length list i
3714
38- -- putStrLn "the length of the list is, "
39- -- print b
40-
41- let b =list_string_lengths list
42-
43- putStrLn "the list of string lengths is, "
44- print b
15+ list_t <- readFile "tdata.dat"
4516
4617
47- let b = sum_string_lengths list
48-
49- putStrLn "the sum of the lengths of the lists is, "
50- print b
51-
18+ let list = lines list_t
5219
5320 let b = entropy_list list
5421
5522 putStrLn "the entropy of the list is, "
5623 print b
5724
58-
59- -- putStrLn "length list is, "
60- -- print (length list)
61-
62- -- let c = gen_past_list list i
63- -- putStrLn "the past of i is, "
64- -- print (c)
65-
6625
6726
6827
6928
7029
30+-- ##############################################################
31+
32+
33+
34+
7135 is_sublist sublist list = sublist `isInfixOf` list
7236
7337
@@ -91,6 +55,9 @@
9155 sum_string_lengths list = sum $ map (count_string_length list) [1..n]
9256 where n = length list
9357
58+my_convert list = lines list
59+
60+
9461 list_string_lengths list = map (count_string_length list) [1..n]
9562 where n = length list
9663
@@ -101,7 +68,8 @@
10168
10269 entropy_list list = 1.0/((pref_list list) * fromIntegral (sum_string_lengths list) )
10370
104-
71+read_file_and_get_entropy list = entropy_list list_new
72+ where list_new = my_convert list
10573
10674
10775 -- ####################################################################################
@@ -110,6 +78,11 @@
11078
11179 convert x = (map (map read . words) . lines) x
11280
81+
82+convert_single_col x = concat $ convert x
83+
84+
85+
11386 firstColumn xss = head (transpose xss)
11487
11588 nthColumn xss n = (transpose xss) !! n -- my first haskell function!