This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
-- frequencies based on large number of text | |
table :: [Float] | |
table = [8.2,1.5,2.8,4.3,12.7,2.2,2.0,6.1,7.0,0.2,0.8,4.0,2.4,6.7,7.5,1.9,0.1,6.0,6.3,9.1,2.8,1.0,2.4,0.2,2.0,0.1] | |
-- earlier functions in the chapter required here | |
lowers :: String -> Int | |
lowers xs = length [ x | x <- xs, isLower x] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- standard library version | |
replicate :: Int -> a -> [a] | |
replicate n x = take n (repeat x) | |
-- my version (having to use list comprehension) | |
replicate' :: Int -> a -> [a] | |
replicate' n x = [x | xn <- [1..n]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- λ <name> <expression> | |
-- lambda forms for myLast and myInit, tested with example list [1,2,3,4] | |
(\x -> head (reverse x))[1,2,3,4] | |
(\x -> take (length x - 1) x) [1,2,3,4] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: Fib.hs | |
-- Task: Generate first n Fibonacci numbers, then sum it | |
-- fib: given n for the index of the Fibonacci series, return the corresponding value, e.g. fib 9 gives 34 | |
fib :: Int -> Int | |
fib 0 = 0 | |
fib 1 = 1 | |
fib n = fib (n-1) + fib (n-2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: myInit.hs | |
-- 2 ways to define init function (removes last element from a non empty list) | |
myInitOne :: [a] -> [a] | |
myInitOne [x] = [] | |
myInitOne (x:xs) = [x] ++ myInitOne xs | |
myInitTwo :: [a] -> [a] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: myLast.hs | |
myLast :: [a] -> a | |
myLast x = head (reverse x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: Clean.hs | |
-- removes null characters | |
import System.Environment (getArgs) | |
removeNull :: [Char] -> [Char] | |
removeNull [] = [] | |
removeNull (x:xs) | |
| x == '\000' = [] ++ removeNull xs | |
| otherwise = [x] ++ removeNull xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: Clean.hs | |
-- removes null characters | |
import System.Environment (getArgs) | |
removeNull :: [Char] -> [Char] | |
removeNull [] = [] | |
removeNull (x:xs) | |
| x == '\000' = [] ++ removeNull xs | |
| otherwise = [x] ++ removeNull xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sort (cost=3357.35..3380.23 rows=9150 width=809) (actual time=147.963..159.258 rows=9429 loops=1) | |
Sort Key: news_article.date_is_published | |
Sort Method: quicksort Memory: 9491kB | |
-> Hash Join (cost=828.56..2755.30 rows=9150 width=809) (actual time=38.766..107.775 rows=9429 loops=1) | |
# additional details etc etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Thu Jun 14 16:57:24 2012] [error] [client 127.0.0.1] mod_wsgi (pid=10827): Exception occurred processing WSGI script '/home/kenny/someapp/wsgi.py'. | |
[Thu Jun 14 16:57:24 2012] [error] [client 127.0.0.1] Traceback (most recent call last): | |
[Thu Jun 14 16:57:24 2012] [error] [client 127.0.0.1] File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py", line 230, in __call__ | |
[Thu Jun 14 16:57:24 2012] [error] [client 127.0.0.1] self.load_middleware() | |
[Thu Jun 14 16:57:24 2012] [error] [client 127.0.0.1] File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 42, in load_middleware | |
[Thu Jun 14 16:57:24 |