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 quickSort (a:_[]) = | |
let rec f _l _r = | |
if _l < _r then | |
let mutable l, r, p =_l, _r, a.[_l] | |
while l <= r do | |
while a.[l] < p do l <- l + 1 | |
while a.[r] > p do r <- r - 1 | |
if l <= r then | |
let t = a.[l] | |
a.[l] <- a.[r] |
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
{-# LANGUAGE GADTs, DataKinds, TypeFamilies, ConstraintKinds, TypeOperators, UndecidableInstances, ExistentialQuantification #-} | |
import GHC.Prim (Constraint) | |
import Data.Ratio ((%)) | |
type family All (cx :: * -> Constraint) (xs :: [*]) :: Constraint | |
type instance All cx '[] = () | |
type instance All cx (x ': xs) = (cx x, All cx xs) | |
data HList (as :: [*]) where |
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 | |
let rec pown x y cont = | |
if y = 1I then cont x else | |
let cont = if y &&& 1I = 0I then cont else (*) x >> cont | |
pown (x*x) (y>>>1) cont | |
let memo = Collections.Generic.Dictionary() | |
let rec A (m:int, n:bigint, cont) = | |
if memo.ContainsKey (m, n) then cont memo.[(m,n)] | |
elif m < 2 then cont (n + 1I + bigint m) |
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
function findImage (mp) { | |
var url = "./data/" + mp.folder + "/" + mp.storage; | |
["", ".jpg", ".png"].map(function(ext) { | |
$("<img/>") | |
.load(function() { mp.storage = mp.storage + ext; }) | |
.attr("src", url + ext); | |
}); | |
} |
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 | |
let inline check< ^a> list = | |
list |> List.iter (fun (name,func: ^a seq ->_) -> | |
try func Seq.empty< ^a> |> ignore | |
with e -> printfn "Seq.%s: %A" name e.Message) | |
check<float> [ | |
"average", Seq.average | |
"averageBy", Seq.averageBy id |
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
[macro name="Macro1"] | |
[call target=*scriptMacro1] | |
[endmacro] | |
[jump target=*nextMacro1] | |
*scriptMacro1 | |
[iscript] | |
.. | |
[endscript] | |
[return] |
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
function isDefined(x) { return x != "undefined" && typeof x !== "undefined"; } |
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 | |
open System.Threading | |
// 進捗を通知する処理を組み立てるビルダーのベースになります | |
type ProgressBaseBuilder () = | |
// calculation は時間のかかる計算で、第1引数は進捗があった時のコールバックです | |
member this.Bind((weight, calculation), remaining) = | |
calculation | |
(fun rate -> rate * weight |> this.report) // 進捗率 x 重み の進捗があったことを通知します |
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 FSharp.Charting | |
open System.Windows.Forms.Integration | |
let hostChart chart = new WindowsFormsHost(Child = new ChartTypes.ChartControl(chart)) |
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 | |
open System.Threading | |
let heavyFuncBase name func v listener = | |
printfn "\r\n%s started..(result = %d)" name v | |
for i in 1..10 do Thread.Sleep 10; listener 0.1 | |
func v | |
let heavyFuncA = heavyFuncBase "A" id 1 | |
let heavyFuncB = heavyFuncBase "B" (fun a -> a + 10) |
OlderNewer