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 NoMonomorphismRestriction, FlexibleContexts #-} | |
| module Parsers | |
| (getCategoryAndEvent, getFields) | |
| where | |
| import Data.Attoparsec.Lazy | |
| import qualified Data.ByteString.Lazy.Char8 as B | |
| import qualified Data.ByteString.Char8 as SB | |
| import Data.List (sort) | |
| spaces :: Parser () |
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 NoMonomorphismRestriction #-} | |
| import Text.Parsec | |
| import Data.List.Split (splitOn) | |
| --field = lexeme $ noneOf " " | |
| field = manyTill anyChar space | |
| logline = do | |
| try (do |
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
| prefixOf [] _ = True | |
| prefixOf (x:xs) (y:ys) = x == y && xs `prefixOf` ys | |
| prefixOf _ _ = False | |
| subListOf l [] = null l | |
| subListOf l m@(_:ys) = l `prefixOf` m || l `subListOf` ys | |
| --not sure if ghc transforms the above, but here's a tail recursive version | |
| subListOf' l [] = null l | |
| subListOf' l m@(_:ys) |
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
| int ints[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
| for (int i = 1; i < 1000000; ++i) std::next_permutation(ints, ints+10); | |
| for (int i = 0; i < 10; ++i) std::cout << ints[i]; |
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
| template <int n, typename Iterator> | |
| class nth_iterator | |
| { | |
| public: | |
| typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category; | |
| typedef typename std::iterator_traits<Iterator>::value_type value_type; | |
| typedef typename std::iterator_traits<Iterator>::difference_type difference_type; | |
| typedef typename std::iterator_traits<Iterator>::pointer pointer; | |
| typedef typename std::iterator_traits<Iterator>::reference reference; | |
| typedef Iterator iterator_type; |
NewerOlder