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
namespace ``When running tests the NaturalSpec library`` | |
open NUnit.Framework | |
open NaturalSpec | |
open System | |
module ``Executing these tests will output meaningful result information`` = | |
let root r = Math.Sqrt r | |
[<Scenario>] | |
let ``Maths is fun`` () = |
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
// F# Solution (ugly): | |
let mapArray s = | |
([|1.0..500.0|] | |
|> Array.map(fun p -> p/2.0*(p+1.0))) | |
|> Array.filter (fun e->e=(s |> Array.sum)) | |
|> Array.length | |
let problem42() = | |
let client = new System.Net.WebClient() | |
client.DownloadString("https://projecteuler.net/project/resources/p042_words.txt").ToUpper().Replace("\"", "").Split([|','|]) |
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
File.ReadAllText("n") | |
.Split(',') | |
.OrderBy(x=>x) | |
.Select((s, i) => s | |
.Replace("\"", string.Empty) | |
.ToCharArray() | |
.Sum(c => c - 64)*++i).Sum(); |
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
//F#: | |
open System | |
let mutable result = [4.0] | |
let problem29 a = | |
for i in [2.0..a] do | |
for e in [2.0..a] do | |
result <- Math.Pow(i, e)::result | |
Seq.distinct result |> Seq.length;; | |
//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
//--------------------------------------------------------------- | |
// Apply Your Knowledge! | |
// | |
// Below is a list containing comma separated data about | |
// Microsoft's stock prices during March of 2012. Without | |
// modifying the list, programatically find the day with the | |
// greatest variance between the opening and closing price. | |
// | |
// The following functions may be of use: | |
// |
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
let logFiles = System.IO.Directory.GetFiles("C:\\temp\\logs") | |
// foreach logfile i want to scan each line and match and select lines containing '9' | |
let selected = | |
logFiles | |
|> Array.map System.IO.File.ReadAllLines | |
let collected = | |
selected |
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
namespace AkkaTypesCS | |
{ | |
public class GreetCs | |
{ | |
public GreetCs(string who) | |
{ | |
Who = who; | |
} | |
public string Who { get; set; } |
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
#load "Spirograph.fs" | |
open System.Drawing | |
open FSharp.TV.Spirograph | |
//let printTurtle turtle = | |
// printfn "%A" turtle | |
// turtle | |
//let repeat (items:seq<'a>) = | |
// let generator state = |
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
#load "Spirograph.fs" | |
open System.Drawing | |
open FSharp.TV.Spirograph | |
let cmdsStripe = | |
[ | |
curve3rd 60.0 5 | |
turn -170.0 | |
move 80 | |
curve3rd 60.0 -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
let (..) (start:int) (limit:int) = | |
let sequence = [start..limit] | |
let decapitate h t = | |
if t = List.empty | |
then [ h ] | |
else t |> List.rev | |
let reversed = | |
match sequence with |
OlderNewer