Skip to content

Instantly share code, notes, and snippets.

open Optimization
open System.Linq
type CheckPoint = {
CPId : string // checkpoint Id
Lat : double // latitude
Lon : double // longitude
}
type InterestPoint = {
lpfib :: Int -> (Int, [Int])
lpfib 0 = (1, [1])
lpfib 1 = (1, [1, 1])
lpfib n = aq `par` bq `pseq` (a + b, as ++ bs ++ [a + b])
where aq@(a, as) = lpfib (n - 1)
bq@(b, bs) = lpfib (n - 2)
-- por ejemplo
main = getArgs >>= mapM_ print . snd . lpfib . read . head
@phatboyg
phatboyg / Program.cs
Last active January 28, 2016 23:37
Example code and output to show the exception being thrown and Fault message being published once with MassTransit 2.9.5 and RabbitMQ
namespace Faulty
{
using System;
using MassTransit;
public interface FaultyCommand
{
string Id { get; }
}
implicit def treeEncode[A: EncodeJson]: EncodeJson[Tree[A]] =
EncodeJson(t => (t.rootLabel, t.subForest).asJson)
implicit def treeDecode[A: DecodeJson]: DecodeJson[Tree[A]] =
DecodeJson(c =>
for {
rootLabel <- (c =\ 0).as[A]
subForest <- (c =\ 1).as[Stream[Tree[A]]]
} yield Tree.node(rootLabel, subForest)
@jpluimers
jpluimers / fix-TiWorker.exe-high-CPU-usage.txt
Created December 11, 2013 11:38
Fixing the high CPU usage of TiWorker.exe
C:\bin>DISM /online /cleanup-image /restorehealth
Deployment Image Servicing and Management tool
Version: 6.2.9200.16384
Image Version: 6.2.9200.16384
[==========================100.0%==========================]
The restore operation completed successfully. The component store corruption was repaired.
The operation completed successfully.
@hafuu
hafuu / ObsoleteAttributeTest
Last active December 30, 2015 03:58
F# 3.1 で ObsoleteAttribute を使うときの注意点? RecordとObsoleteAttributeは相性が悪いようだ。もしRecordをObsoleteにするなら、すべてのフィールドにObsoleteAttributeを付けたほうが良さそう。
module ObsoleteAttributeTest
open System
module Record =
[<Obsolete>]
type Foo = {
A: string
B: int
}
@panesofglass
panesofglass / RootR.mbp.fs
Last active December 29, 2015 17:59
Schema for a routing type provider
type App = Routes<"path to spec">
App.RootR.Get(fun request -> async { return! process request })
// This sets the implementation for the GET on the root.
// The MbP contains the logic to write the response to the underlying socket stream.
anonymous
anonymous / contratests.fs
Created November 22, 2013 23:12
module Test.z
/// Actual test function
type 'a TestCode = 'a -> unit
/// Test tree
type 'a Test =
| TestCase of 'a TestCode
| TestList of 'a Test seq
| TestLabel of string * 'a Test
@tpolecat
tpolecat / gist:7401433
Last active August 29, 2020 08:00
set is not a functor mkay
scala> case class Bad(a: Int) { override def equals(a:Any) = true }
scala> val f = (n:Int) => Bad(n)
scala> val g = (b:Bad) => b.a
...
scala> Set(1,2,3).map(f andThen g)
res2: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
scala> Set(1,2,3).map(f).map(g)
@ion1
ion1 / 0README.md
Last active August 30, 2020 08:04
What is inside Haskell IO?

What is inside Haskell IO?

<lambdabot> shachaf says: getLine :: IO String contains a String in the same
            way that /bin/ls contains a list of files

There are multiple ways IO could be implemented internally. Here’s a demonstration of one.

MiniIO (below) implements an ADT of arbitrarily chosen primitives that represent I/O operations and a way to combine them. One can create, evaluate and manipulate MiniIO values without causing any side effects to occur. That is what example in Main.hs does. The same applies to real IO values in Haskell: you can create a big list of print "hello"s and later pick which ones to actually execute.