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
#light | |
namespace Microsoft.MapReduce | |
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | |
[<CompilationMapping(SourceConstructFlags.Module)>] | |
module String = | |
open System.Text.RegularExpressions | |
let words (s:string) : string list = |
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
#light | |
type ICustomerRepository = | |
abstract GetCustomersWithFirstNameOf : string -> seq<Customer> | |
let test_lookup() = | |
let repository = { new ICustomerRepository with | |
member this.GetCustomersWithFirstNameOf(name) = | |
[{ CustomerName = name; Address = "1 Microsoft Way"; City = "Redmond"; State = "WA" }] | |
} |
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
#light | |
namespace CodeBetter.Extensions | |
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | |
[<CompilationMapping(SourceConstructFlags.Module)>] | |
module List = | |
// Insert | |
// The non-overloaded version of 'insert' |
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
#light | |
open System | |
module List = | |
let to_string (xs:char list) : string = | |
new string(Array.of_list xs) | |
module Char = | |
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
#light | |
module Char = | |
open System | |
let isAlpha = Char.IsLetter | |
let isDigit = Char.IsDigit | |
let isHexDigit c = |
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
public static IEnumerable<T> Filter<T>(this IEnumerable<T> items, Func<T, bool> pred) | |
{ | |
return items.Aggregate<T, Func<IEnumerable<T>, IEnumerable<T>>>( | |
x => x, (f, c) => x => f(pred(c) ? (new [] { c }).Concat(x) : x))(Enumerable.Empty<T>()); | |
} | |
public static IEnumerable<R> Map<T, R>(this IEnumerable<T> items, Func<T, R> proj) | |
{ | |
return items.Aggregate<T, Func<IEnumerable<R>, IEnumerable<R>>>( | |
x => x, (f, c) => x => f((new[] { proj(c) }).Concat(x)))(Enumerable.Empty<R>()); |
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
[Fact] | |
public void TestSpecificationCollection() | |
{ | |
var minCredit = 3; | |
var product = new Product() { MinimumCreditRating = minCredit, Price = 50 }; | |
var spec = new EligibleForDiscountSpecification(product); | |
var customers = new List<Customer>() | |
{ | |
new Customer() {CreditRating = minCredit-2}, // bad credit |
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
-- Haskell | |
identity :: [a] -> [a] | |
identity xs = foldr (:) [] xs | |
// F# | |
let identity (xs:'a list) : 'a list = List.fold_right (::) [] xs;; |
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
-- Haskell | |
fibs = 0 : 1 : zipWith (+) fibs (tail fibs) | |
// F# | |
let rec fibs : LazyList<int> = | |
LazyList.cons 0 (LazyList.cons 1 (fun() -> (LazyList.map2 (+) fibs (LazyList.tl fibs)))) | |
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
-- Haskell | |
(.) :: (b -> c) -> (a -> b) -> a -> c | |
// F# | |
val (<<) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b | |
val (>>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c | |
val (|>) : 'a -> ('a -> 'b) -> 'b | |
val (<|) : ('a -> 'b) -> 'a -> 'b |
OlderNewer