packages feed

acme-colosson (empty) → 0.1

raw patch · 4 files changed

+84/−0 lines, 4 filesdep +basedep +randomsetup-changed

Dependencies added: base, random

Files

+ Acme/Colosson.hs view
@@ -0,0 +1,34 @@+-- | Determines whether it is numberwang.+module Acme.Colosson+    ( numberwang+    ) where++import System.Random+import System.IO.Unsafe++data Wanger = Numb Bool Wanger Wanger++simon :: Wanger -> Integer -> Bool+simon (Numb b _ _) 0 = b+simon (Numb _ x y) n = case divMod n 2 of+    (m, 0) -> simon x m+    (m, _) -> simon y m++julie :: StdGen -> Wanger+julie g0 =+    let (b,  g1) = random g0+        (g2, g3) = split  g1+    in  Numb b (julie g2) (julie g3)++colosson :: IO (Integer -> Bool)+colosson = do+    nt <- julie `fmap` newStdGen+    pt <- julie `fmap` newStdGen+    let f n | n < 0     = simon nt (-n)+            | otherwise = simon pt n+    return f++-- | Is it numberwang?+numberwang :: Integer -> Bool+numberwang = unsafePerformIO colosson+{-# NOINLINE numberwang #-}
+ LICENSE view
@@ -0,0 +1,26 @@+Copyright (c) Keegan McAllister 2011++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the distribution.+3. Neither the name of the author nor the names of his contributors+   may be used to endorse or promote products derived from this software+   without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,4 @@+#! /usr/bin/runhaskell++import Distribution.Simple+main = defaultMain
+ acme-colosson.cabal view
@@ -0,0 +1,20 @@+name:                acme-colosson+version:             0.1+license:             BSD3+license-file:        LICENSE+synopsis:            Determines whether it is numberwang.+category:            Acme+author:              Keegan McAllister <mcallister.keegan@gmail.com>+maintainer:          Keegan McAllister <mcallister.keegan@gmail.com>+build-type:          Simple+cabal-version:       >=1.2+description:+    Yes, that is a number!++library+  exposed-modules:+      Acme.Colosson+  ghc-options:      -Wall+  build-depends:+      base   >= 3 && < 5+    , random >= 1.0