Haskell moment

Here are some Haskell code chunks, which both are simple recursion algorithms.

Quicksort is a sort of poster child for Haskell because everyone does it to showcase how elegant Haskell is.

quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort [a | a <- xs, a <= x]
    biggerSoted = quicksort [a | a <- xs, a > x]
in smallerSorted ++ [x] ++ biggerSoted
maximum' :: (Ord a) => [a] -> a
maximum' [] = error "List is empty!"
maximum' [x] = x
maximum' (x:xs) = (max x (maximum' xs))

replicate' :: Int  -> b -> [b]
replicate' n x
    | n <= 0 = []
    | otherwise = (x:(replicate' (n-1) x))

take' :: Int -> [a] -> [a]
take' n (x:xs)
    | n <= 0 = []
    | otherwise = x:(take' (n-1) xs)

reserve' :: [a] -> [a]
reserve' [] = []
reserve' (x:xs) = (reserve' xs) ++ [x]

Keep going

Listen, smile, agree, and then do whatever the fuck you were gonna do anyway.

最近其实挺迷茫的。

因为还有不到一年的时间就要结束自己的研究生阶段了。但是感觉还有很多事情没有实现。比如到底是继续读博还是工作;是在国内发展还是在国外发展;让体重身材变得正常;说流利的英语;老妈一直关心的找女朋友。

每件事情其实都不是一蹴而就的。我一直相信现在的自己,藏着所有走过的路,读过的书和喜欢崇拜过的人。如果让我现在就决定到底要不要读博士或者去工作的话,真的很难。所以说我只有每天都让自己变得好一点,多看看书,多去健身房运动一下,还有多参加俱乐部认识新的朋友。总有那么一天,在积累了足够多的努力之后,成功就会追上你了。

最近因为学校的事情不得不回学校上课,非常感谢小槐树可以认可我,让我可以假期再回微软玩耍。所以想一想,其实生活中还是有很多好的事情在发生的嘛。

然后是最近的规划。因为刚开学,除了上课还是比较轻松的。希望可以利用这段时间认识一些新的朋友,学一些新的知识,努力充实自己:)