Haskell

文字列のSHA1をとる

こうかなあ。 import Codec.Binary.UTF8.String (encode) import Data.ByteString.Lazy (pack) import Data.Digest.Pure.SHA (showDigest, sha1) main = do putStr $ showDigest $ sha1 $ pack $ encode "寿限無寿限無五劫の擦り切れ海砂利水魚の水行末雲来…

ファイルのパスを操作する関数

System.FilePathモジュールにあります (http://hackage.haskell.org/packages/archive/filepath/1.1.0.2/doc/html/System-FilePath.html).

printf

Text.Printfモジュールにあります (http://cvs.haskell.org/Hugs/pages/libraries/base/Text-Printf.html).

リンクエラー

問題 GHC 6.12.2を使って、Text.Regex.Posixモジュールをimportしているコードをコンパイルしようとすると、 ghc -o sourcegrep Main.hs compilation IS NOT required Main.o: In function `s1z1_info': (.text+0x28f1): undefined reference to `__stginit_…

論理否定

not演算子を使います。 $ ghci GHCi, version 6.12.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading …

パスの中のファイル名を得る

System.FilePathモジュールのtakeFileNameが使えます。 $ ghci GHCi, version 6.12.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base …

論理積と論理和

&&演算子と||演算子を使います。 $ ghci GHCi, version 6.12.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done.…

接頭辞かどうか判定する

Data.ListモジュールのisPrefixOfを使います。 $ ghci GHCi, version 6.12.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... link…