- 總共有 7 位參與者
- 檢測質數的方法大同小異,但因為生成與檢驗的次序不同,造成執行速度極大的差異
- lazy evaluation 是個雙面刃:
- 讓我們在 Haskell 可以用直覺且高效的方式去實作許多在其他語言看似不可能的方法(例如先將所有的質數枚舉出來)
- 但同時也讓程式的 cost centre 非常難去分析
- 經過不科學 benchmark,小編挑出了跑得最快的前三名,在此各頒發 emoji 一枚 🎉🎉🎉
- Tai An Su 🥇
- 洪崇凱 🥈
Windows 64-bit 一鍵安裝包:http://www.cs.uiowa.edu/~astump/agda/ (備用連結(比較快)) 本安裝檔包含 GHC 7.8、Agda 2.4 以及 Emacs
- Haskell
ghc
與ghci
,GHC 提供的 Haskell 編譯器與交互式直譯器- 建議版本為 **GHC 7.8 (較舊版本例如 **7.6 也可以接受,而更新的版本 prelude 所提供的函數型別會與教學使用的有些落差)
- Agda
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
#!/bin/bash | |
# Config | |
# Le script quitte en cas d'erreur d'une commande | |
set -o errexit | |
# Le script quitte en cas de variables non déclarée | |
set -o nounset | |
# Script path |
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
{-# LANGUAGE OverloadedStrings, DataKinds, DeriveGeneric, TypeFamilies #-} | |
module MQ where | |
import Database.Edis | |
import Data.ByteString | |
import Data.Serialize hiding (Get) | |
import GHC.Generics | |
data Message = Msg ByteString Integer deriving (Show, Generic) |
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
{-# LANGUAGE OverloadedStrings, DataKinds, DeriveGeneric #-} | |
module MQ where | |
import Database.Edis | |
import Data.ByteString | |
import Data.Serialize | |
import GHC.Generics | |
data Message = Msg ByteString Integer deriving (Show, Generic) |
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
{-# LANGUAGE OverloadedStrings, DataKinds, DeriveGeneric #-} | |
module MQ where | |
import Database.Edis | |
import Data.ByteString | |
import Data.Serialize | |
import GHC.Generics | |
data Message = Msg ByteString Integer deriving (Show, Generic) |