测试Hakyll和Github Pages

March 19, 2013

代码

~~~~~~ 间插入代码块:

~~~ {.haskell}
main = fix error
~~~

得到:

main = fix error

可以加行数:

~~~ {.c .numberLines}
int main()
{
    printf("Hello, World!");
    main();
}
~~~

效果:

1
2
3
4
5
int main()
{
    printf("Hello, World!");
    main();
}

(代码里混用Tab和空格缩进会很麻烦, 代码框变小了是CSS没弄好)

数学公式

$和$之间得内容会被当作 \(\TeX\) 数学公式:

$\pi = 3.1415926...$

得到

\(\pi = 3.1415926...\)

夸行没问题:

$\begin{align}
P(Y, E = e) & = {1 \over Z} * {\prod \phi^\prime_k(D^\prime_k)} \\
            & \propto \prod{k}\phi^\prime_k(D^\prime_k) \\
\end{align}$

\(\begin{align} P(Y, E = e) & = {1 \over Z} * {\prod \phi^\prime_k(D^\prime_k)} \\ & \propto \prod{k}\phi^\prime_k(D^\prime_k) \\ \end{align}\)

这是什么啊?

最后来点Haskell代码:

module Knight where

import Control.Monad.Writer
import Data.List (nub, sort)

next (x, y) = [(x + dx, y + dy) | dx <- [-2, -1, 1, 2]
                                , dy <- [-2, -1, 1, 2]
                                , abs dx + abs dy == 3]

inBoard (x, y) = x > 0 && y > 0 && x <= 8 && y <= 8

paths from to step ps
    | step < 0 = return ()
    | from == to && step >= 0 = tell [ps]
    | otherwise =
        let possibleSteps = filter inBoard (next from)
        in mapM_ (\f -> paths f to (step - 1) (f:ps)) possibleSteps

result from to step = runWriter (paths from to step [from])