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
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using Xunit; | |
public class When_overriding_GetHashCode | |
{ | |
[Fact] | |
public void Equals_should_be_overridden() | |
{ |
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
public IEnumerable<IResult> DoSomethingBaseOnType(SomeBaseClass item) | |
{ | |
var function = _typeToFunction[item.GetType()]; | |
foreach (var result in function(item)) | |
{ | |
yield return result; | |
} | |
} |
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
// what's a better way? | |
let fullName (first,last) = | |
match (first, last) with | |
"",_ | null,_ -> first | |
| _,null | _,"" -> last | |
| _ -> sprintf "%s.%s" first 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
open System | |
open System.ComponentModel | |
open System.Web.Mvc | |
open Microsoft.FSharp.Reflection | |
// inspired by http://www.atrevido.net/blog/CommentView,guid,d5591bdc-add1-4fbc-b1d9-0c25359433a6.aspx | |
type MyModelBinder() = | |
let rec makeDefaultRecord ty = |
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
// imperative version - uses a loop | |
static int Reduce(Func<int, int, int> reducer, IEnumerable<int> values) | |
{ | |
int accum = 0; | |
foreach (var i in values) | |
{ | |
accum = reducer(accum, i); | |
} | |
return accum; | |
} |
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
// functional version - recursion instead of a loop | |
static int ReduceF(Func<int, int, int> reducer, IEnumerable<int> values, int seed) | |
{ | |
return values.Any() | |
? ReduceF(reducer, values.Skip(1), reducer(seed, values.First())) | |
: seed; | |
} |
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
type Shape = | |
| Circle of float | |
| Rectangle of double*double | |
| EquilateralTriangle of double | |
let pi = 3.141592654 | |
let area shape = | |
match shape with | |
| Circle r -> r*r*pi |
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
namespace Raven.Tests.Silverlight | |
{ | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Client.Document; | |
using Client.Extensions; | |
using Database.Data; | |
using Database.Indexing; | |
using Document; |
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
[Fact] | |
public void Can_insert_async_and_get_sync() | |
{ | |
using (var server = GetNewServer(port, path)) | |
{ | |
var documentStore = new DocumentStore { Url = "http://localhost:" + port }; | |
documentStore.Initialize(); | |
var entity = new Company { Name = "Async Company" }; | |
using (var session = documentStore.OpenAsyncSession()) |
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
/*jslint evil: true, white: true, onevar: true, undef: true, nomen: true, regexp: true, plusplus: true, bitwise: true, newcap: true, maxerr: 10, indent: 4 */ | |
/*global JSLINT, WScript, ActiveXObject, Enumerator*/ | |
(function () { | |
var jslint_path = 'jslint.js', | |
jslint_source = '', | |
utf8 = '', | |
fso = new ActiveXObject('Scripting.FileSystemObject'), | |
files = [], | |
args = WScript.Arguments; |
OlderNewer