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 Euler3 where | |
{- | |
The prime factors of 13195 are 5, 7, 13 and 29. | |
What is the largest prime factor of the number 600851475143 ? | |
-} | |
factorOf :: Int -> Int -> Bool | |
a `factorOf` b = rem b a == 0 |
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
package com.jnape.dynamiccollection; | |
import com.jnape.dynamiccollection.lambda.Function; | |
import com.jnape.dynamiccollection.list.CachingStream; | |
import com.jnape.dynamiccollection.list.DynamicList; | |
import com.jnape.dynamiccollection.list.Stream; | |
import static com.jnape.dynamiccollection.lambda.library.numeric.accumulator.Add.add; | |
import static com.jnape.dynamiccollection.list.NumericDynamicArrayList.numbers; |
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 Primes where | |
main :: IO () | |
main = print $ take 1000 primes | |
(√) :: Int -> Int | |
(√) = floor . sqrt . fromIntegral | |
primes :: [Int] | |
primes = 2 : sieve [3, 5..] |
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 PrimeFactorization where | |
import Data.List | |
primeFactorsOf :: Int -> [Int] | |
primeFactorsOf n = (nub . unfoldr (2 `factorOutOf`)) n | |
where k `factorOutOf` n | |
| n < 2 = Nothing | |
| n `mod` k == 0 = Just (k, n `div` k) | |
| otherwise = (k+1) `factorOutOf` n |
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 Snippet where | |
import Data.List | |
compress :: String -> String | |
compress = (foldl1 (++)) . (foldl (\acc xs -> acc ++ [(show.length) xs, (head xs):[]]) []) . group | |
compressions :: String -> [String] | |
compressions x = let n = compress x in n:compressions n |
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 GroupSort ( | |
groupsort | |
) where | |
groupsort :: Ord a => [a] -> [a] | |
groupsort [] = [] | |
groupsort xs = let | |
groups = group xs | |
n = length xs | |
k = length groups |
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
package com.thoughtworks.futureeither | |
import concurrent.{Await, Future} | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import concurrent.duration.FiniteDuration | |
import java.util.concurrent.TimeUnit | |
class FutureEither[L, R](private val future: Future[Either[L, R]]) { | |
def flatMap[R2](block: R => FutureEither[L, R2]): FutureEither[L, R2] = { |
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
package com.thoughtworks.futureeither | |
import scala.collection.mutable | |
abstract sealed class LoopOutcome { | |
def endOrElse(fn: => Any) = this match { | |
case Repeat() => fn | |
case _ => | |
} |
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
from unittest2 import TestCase | |
from mockito import when, unstub | |
from uuid import UUID | |
import uuid | |
def use_mocking(test_suite): | |
wrapped_tearDown = test_suite.tearDown if 'tearDown' in dir(test_suite) else lambda self: True | |
def tearDown(self): |
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
% The person who has to deploy to Mobile is not Max or Sam | |
% Neither Max or Charlie are fans of Copying Files | |
% The one who deploys quarterly does so to a Mobile target | |
% Andy deploys weekly | |
% The person making use of a third party PAAS is not Andy or Charlie | |
% Sam is either the Copying Files or the System Package enthusiast | |
% The person who makes VM Images is not Charlie and doesn’t own deploy to a PAAS | |
% The person who deploys to the PAAS is does so more frequently than the person who deploys to the Desktop | |
% Of the System Packaging fan and Charlie, one deploys monthly and the other deploys to Mobile | |
% The person who deploys to the IAAS is not Max |