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 Control.Monad.State | |
import System.Random | |
type Field = String | |
replaceField :: String -> Field -> Field | |
replaceField newContent field = | |
let fieldName = takeWhile (/=':') field | |
in fieldName ++ ": " ++ newContent |
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
randomMonth :: (RandomGen g) => State g String | |
randomMonth = | |
let monthNames = [ "January", "February", "March" | |
, "April", "May", "June" | |
, "July", "August", "September" | |
, "October", "November", "December" | |
] | |
in (monthNames !!) <$> randomNumber (1,11) | |
randomNumber :: (RandomGen g) => (Int,Int) -> State g Int |
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
runKoan :: Koan -> IO Bool | |
runUntilFail :: [Koan] -> IO () | |
runUntilFail [] = return () | |
runUntilFail (x:xs) = do | |
continue <- runKoan x | |
when continue $ runUntilFail xs |
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
[Test] | |
public void ShouldNotReturnNullWebServiceResponse() | |
{ | |
var iv_client = Substitute.For<Client>(); | |
iv_client.GetValuation("G1|12345", 10000, 2008, "08").Returns(new WebServiceResponse() | |
{ | |
Result = false, | |
ErrorEnum = IdResponseCode.NoDataFound | |
}); |
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 Control.Arrow ((>>>)) | |
import Data.List.Zipper | |
import Data.Maybe | |
{- ref: | |
- http://www.reddit.com/r/dailyprogrammer/comments/12qi5b/1162012_challenge_111_easy_star_delete/ | |
- -} | |
starDelete' :: String -> String | |
starDelete' [] = [] |
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
[Test] | |
public void TEST() | |
{ | |
var results = FirstResults().Concat(GetResults()); | |
Console.WriteLine("results created"); | |
Console.WriteLine("get first"); | |
results.First(); | |
Console.WriteLine("get last"); |
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
error FS0193: internal error: Value cannot be null. | |
Parameter name: con |
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
// See also: http://davesquared.net/2012/12/lazy-monad-csharp.html | |
public static class LazyExtensions | |
{ | |
public static Lazy<TResult> Select<T, TResult>(this Lazy<T> value, Func<T, TResult> selector) | |
{ | |
return new Lazy<TResult>(() => selector(value.Value)); | |
} | |
public static Lazy<TResult> SelectMany<T, TResult>(this Lazy<T> value, Func<T, Lazy<TResult>> selector) |
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
class Maybe | |
def self.empty | |
Maybe.new nil | |
end | |
def initialize(value) | |
@value = value | |
end | |
def bind(f) | |
@value.nil? ? self : f.call(@value) | |
end |
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
"Is Clojure code hard to understand? Imagine if every time you read Java source code and encountered syntax elements like if statements, for loops, and anonymous classes, you had to pause and puzzle over what they mean. There are certain things that must be obvious to a person who wants to be a productive Java developer. Likewise there are parts of Clojure syntax that must be obvious for one to efficiently read and understand code. Examples include being comfortable with the use of let, apply, map, filter, reduce and anonymous functions ..." | |
-- R. Mark Volkmann, http://java.ociweb.com/mark/clojure/article.html |