This file contains 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 main(int argc, char** argv) { | |
using namespace folly::gen; | |
auto v = from (m) | mapped(f) | as<vector>(); | |
return v.size(); | |
} |
This file contains 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
module Search where | |
import Control.Applicative | |
import Control.Monad | |
import Data.Foldable | |
import Data.Monoid | |
import Data.Sequence | |
import Data.Traversable | |
import Prelude hiding (foldl) | |
import Test.QuickCheck |
This file contains 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
("/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs" "search.hs") | |
Loading /Users/tulloch/.emacs.d/tulloch.el (source)...done | |
For information about GNU Emacs and the GNU system, type C-h C-a. | |
Loading vc-git...done | |
Contacting host: api.github.com:443 | |
Opening TLS connection to `api.github.com'... | |
Opening TLS connection with `gnutls-cli --insecure -p 443 api.github.com'...failed | |
Opening TLS connection with `gnutls-cli --insecure -p 443 api.github.com --protocols ssl3'...failed | |
Opening TLS connection with `openssl s_client -connect api.github.com:443 -no_ssl2 -ign_eof'...done | |
Opening TLS connection to `api.github.com'...done |
This file contains 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
module Search where | |
import Control.Applicative | |
import Control.Monad | |
import Data.Foldable | |
import Data.Monoid | |
import Data.Sequence | |
import Data.Traversable | |
import Prelude hiding (foldl) | |
import Test.QuickCheck |
This file contains 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
Welcome to the Emacs shell | |
~/Code/haskell/search $ runhaskell search.hs | |
Passed: | |
1 | |
Leaf 0 | |
Passed: | |
1 | |
Branch (Leaf (-1)) (Leaf 1) | |
Passed: |
This file contains 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
module Search where | |
import Control.Applicative | |
import Control.Monad | |
import Data.Foldable | |
import Data.Monoid | |
import Data.Sequence | |
import Data.Traversable | |
import Prelude hiding (foldl) | |
import Test.QuickCheck |
This file contains 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
search :: Eq a => Expand a -> a -> Seq (Node a) -> Bool | |
search expand target queue = | |
let recur = search expand target | |
in case viewl queue of | |
EmptyL -> False | |
Leaf value :< xs -> (value == target) || recur xs | |
Branch left right :< xs -> | |
recur (expand xs left right) |
This file contains 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
search :: Eq a => Expand a -> a -> Seq (Node a) -> Bool | |
search expand target queue = | |
let recur = search expand target | |
in case viewl queue of | |
EmptyL -> False | |
Leaf value :< xs -> (value == target) && recur xs | |
Branch left right :< xs -> | |
recur (expand xs left right) |
This file contains 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
Welcome to the Emacs shell | |
~/Code/haskell/search $ runhaskell search.hs | |
Failed: | |
0 | |
Leaf 0 | |
*** Failed! Falsifiable (after 1 test): | |
0 | |
Leaf 0 | |
~/Code/haskell/search $ |
This file contains 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
~/Code/haskell/search $ runhaskell search.hs | |
Failed: | |
0 | |
Leaf 0 | |
*** Failed! Falsifiable (after 1 test): | |
0 | |
Leaf 0 |
OlderNewer