Created
April 14, 2009 13:33
-
-
Save tom-lpsd/95180 to your computer and use it in GitHub Desktop.
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 Database.TokyoCabinet.BDB | |
import qualified Database.TokyoCabinet.BDB.Cursor as C | |
import Data.ByteString.Char8 (ByteString, unpack) | |
myCMP :: ByteString -> ByteString -> Ordering | |
myCMP k1 k2 = compare (reverse (unpack k1)) (reverse (unpack k2)) | |
main = do bdb <- new | |
setcmpfunc bdb (CMP myCMP) | |
open bdb "foo.tcb" [OWRITER, OCREAT] | |
put bdb "abz" "100" | |
put bdb "def" "200" | |
cur <- C.new bdb | |
C.first cur | |
Just key <- C.key cur | |
putStrLn key | |
close bdb | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment