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
open System | |
/// Finnish social security number calculator in F# | |
/// Suomalainen henkilötunnuslaskuri F#:lla | |
module SSN = | |
let getSeparator year = | |
if year < 1900 then '+' | |
else if year < 2000 then '-' | |
else 'A' |
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 IpToCountry | |
open System | |
open System.IO | |
/// Construct new class for mapping ip addresses to countries using | |
/// database from http://software77.net/geo-ip/ | |
type IpToCountrySlow(?fileName) = | |
let fileName = defaultArg fileName "IpToCountry.csv" | |
// Read all non-comment lines |
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 IpToCountry | |
open System | |
open System.IO | |
type CountryCode = { code : string } | |
type IpAddressMapping = { cc : CountryCode; startAddress : uint32; } | |
/// Class to store the IP-addresses in 255 different buckets | |
/// countryIpList = The list of IP address mappings to store in this intance |
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
#include <string> | |
#include <fstream> | |
#include <vector> | |
#include <sstream> | |
#include <algorithm> | |
#include <stdexcept> | |
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { | |
std::stringstream ss(s); | |
std::string item; |
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
#include <string> | |
#include <fstream> | |
#include <vector> | |
#include <sstream> | |
#include <algorithm> | |
#include <iostream> | |
#include <stdexcept> | |
#include <array> | |
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { |
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
// FSharp (F#) interpreter for brainfuck programming language | |
// Read more from | |
// - http://www.muppetlabs.com/~breadbox/bf/ | |
// - http://fsharp.net | |
// (c) 2011 Markus Lindqvist | |
module brainfuck | |
open System | |
let brainfuckMemorySize = 30000 |
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 "FsharpChart.fsx" | |
open MSDN.FSharp.Charting | |
let castValue (value : 'TSource) :'TResult = | |
let an = new System.Reflection.AssemblyName("CastUtil") | |
let ab = System.AppDomain.CurrentDomain.DefineDynamicAssembly(an, System.Reflection.Emit.AssemblyBuilderAccess.RunAndSave) | |
let mb = ab.DefineDynamicModule(an.Name) | |
let tb = mb.DefineType("CastUtil", System.Reflection.TypeAttributes.Public ||| System.Reflection.TypeAttributes.Class) | |
let fb = tb.DefineMethod("Read", System.Reflection.MethodAttributes.Public ||| System.Reflection.MethodAttributes.Static, typeof<'TResult>, ([|typeof<'TSource>|])) | |
let ig = fb.GetILGenerator() |
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
/// Read more about EOQ from http://en.wikipedia.org/wiki/Economic_order_quantity | |
/// Using functional approach to handle user interface interaction using reactive programming style. | |
/// Any comments and improvements welcome :-) | |
/// -Markus L/2011 | |
#if INTERACTIVE | |
#r "PresentationCore" | |
#r "PresentationFramework" | |
#r "System.Xaml" |
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
/// Implementation for GCHQ Challenge stage 2 virtual machine, in F# | |
/// From: http://canyoucrackit.co.uk/codeexplained.asp?v=1 | |
/// This is a JavaScript programming challenge, with a cyber security angle. To solve | |
/// this stage an implementation of a simple virtual processor is required. Some notes | |
/// on the architecture are provided along with a block of data that can be analysed. | |
/// Solving this stage will reveal the final stage of the challenge. | |
/// The challenge originally suggested writing a virtual machine for the given instructions in JavaScript, but I decided to go with F# | |
/// See original 15b436de1f9107f3778aad525e5d0b20.js at http://pastebin.com/p5AHwPra | |
/// |
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
/// FSharp translation of the Cohen–Sutherland 2D line clipping algorithm | |
/// http://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm | |
/// | |
/// Implemented in purely functional form which means there are no mutable variables. | |
/// No guarantees are given on the performance or reliability, it's not | |
/// thoroughly tested so feel free to submit unit tests. :-) | |
/// | |
/// Markus Lindqvist 07/2012 | |
module CohenSutherland |
OlderNewer