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# code for the k-nucleotide task | |
// This is ~3.6x faster than the solution currently on The Computer Language Benchmarks Game. | |
// The optimisations are described in detail in the F# Journal article: | |
// "Optimising k-nucleotide" -- http://fsharpnews.blogspot.com/2013/08/optimizing-k-nucleotide.html | |
module Sub = | |
let maxLength = 29 | |
let lengthPos = maxLength*2 | |
let bits length = (1UL <<< (2*length)) - 1UL | |
let codeMask = bits maxLength |
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
#define X_STEP_PIN 54 | |
#define X_DIR_PIN 55 | |
#define X_ENABLE_PIN 38 | |
#define X_MIN_PIN 3 | |
#define X_MAX_PIN 2 | |
#define Y_STEP_PIN 60 | |
#define Y_DIR_PIN 61 | |
#define Y_ENABLE_PIN 56 | |
#define Y_MIN_PIN 14 |
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 SciMark2 | |
module Random = | |
let m = Array.create 17 0 | |
let mutable i = 4 | |
let mutable j = 16 | |
let mdig = 32 | |
let m1 = (1 <<< mdig - 2) + ((1 <<< mdig - 2) - 1) | |
let m2 = 1 <<< mdig / 2 | |
let dm1 = 1.0 / float m1 |
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 Random = struct | |
let m = Array.create 17 0 | |
let i = ref 4 | |
let j = ref 16 | |
let mdig = 32 | |
let m1 = (1 lsl (mdig - 2)) + (1 lsl (mdig - 2)) - 1 | |
let m2 = 1 lsl (mdig / 2) | |
let dm1 = 1.0 /. (2. ** float(mdig-1) -. 1.) | |
let nextDouble() = |
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 "stdafx.h" | |
#include <iostream> | |
#include <unordered_set> | |
using namespace std; | |
typedef pair<int, int> P; | |
template <class T> struct MyHash; | |
template<> struct MyHash<P> |
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
type [<Struct>] P = | |
val i : int | |
val j : int | |
new(i, j) = {i=i; j=j} | |
let cmp = | |
{ new System.Collections.Generic.IEqualityComparer<P> with | |
member __.Equals(this, that) = | |
this.i = that.i && this.j = that.j | |
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
use std::collections::HashSet; | |
use std::hash::BuildHasherDefault; | |
use std::default::Default; | |
use std::hash::Hasher; | |
pub struct FnvHasher(u64); | |
impl Default for FnvHasher { | |
#[inline] |
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.Collections.Generic | |
type [<Struct>] P = | |
val i : int | |
val j : int | |
new(i, j) = {i=i; j=j} | |
let cmp = | |
{ new System.Collections.Generic.IEqualityComparer<P> with | |
member __.Equals(this, that) = |
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
use std::collections::HashSet; | |
use std::hash::BuildHasherDefault; | |
use std::default::Default; | |
use std::hash::Hasher; | |
pub struct FnvHasher(u64); | |
impl Default for FnvHasher { | |
#[inline] |
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 accountFactor = function | |
| `Simple -> 0.9 | |
| `Valuable -> 0.7 | |
| `MostValuable -> 0.5 | |
let loyaltyFactor years = | |
1.0 -. float(min years 5) /. 100.0 | |
let applyDiscount price = function | |
| `Unregistered -> price |
OlderNewer