This file contains hidden or 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
Filter(function(e) is.function(eval(e)), as.list(parse("test.R", keep.source = TRUE))) |
This file contains hidden or 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
R Package is created: see https://github.com/kos59125/RaaS |
This file contains hidden or 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
calc_pi <- function(n, k) { | |
stopifnot(n %% k == 0) | |
r <- n %/% k | |
s <- 0 | |
for (loop in seq_len(r)) { | |
x <- runif(k) | |
y <- runif(k) | |
s <- s + sum(x * x + y * y <= 1) | |
} | |
4 * s / n |
This file contains hidden or 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
library(magrittr) | |
takewhile <- function(zoi, count=0L) { | |
count <- count + 1L | |
if (eval(zoi)) { | |
return(count) | |
} else { | |
return(takewhile(zoi, count)) | |
} | |
} |
This file contains hidden or 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 FsRandom | |
let sampleOne array = random { | |
let! sample = Array.sample 1 array | |
return sample.[0] | |
} | |
let zoi = | |
[[|"今日"; "ぞい"|]; [|"も"|]; [|"1"; "ぞい"|]; [|"日"; "ぞい"|]; [|"がん"; "ぞい"|]; [|"ばる"; "ぞい"|]; [|"ぞい!"|]] | |
|> List.map sampleOne |
This file contains hidden or 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 TestResult = | |
| Success | |
| Failure of string | |
type TestState<'a, 'b, 'c> = | |
| NotRun | |
| Context of 'a | |
| Action of 'b | |
| Response of 'c | |
| Result of TestResult |
This file contains hidden or 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 FsRandom | |
let search goal state = | |
// 入力から文字種を得る | |
let goalSize = String.length goal | |
let input = Seq.distinct goal |> Seq.toArray | |
let inputSize = Array.length input | |
use e = | |
Utility.chooseOne inputSize | |
|> Random.map (fun index -> input.[index]) |
This file contains hidden or 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 FsRandom | |
let randomCell = | |
String.randomAlphabet 4 | |
|> Random.map (fun s -> s.ToUpper ()) | |
Seq.unfold (function | |
| _, true -> None | |
| s, _ -> | |
match Random.next randomCell s with |
This file contains hidden or 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 Quotations.ComputationExpressionPatterns | |
open Microsoft.FSharp.Quotations.Patterns | |
let (|MethodNamedAs|_|) name = function | |
| Call (Some (builder), mi, args) when mi.Name = name -> Some (builder, mi, args) | |
| _ -> None | |
let (|Bind|_|) = function | |
| MethodNamedAs "Bind" (builder, methodInfo, [m; f]) -> Some (builder, methodInfo, m, f) | |
| _ -> None |
This file contains hidden or 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
(* | |
"Debugging MCMC" http://blog.recyclebin.jp/archives/4216 | |
Usage | |
------ | |
nuget install -x FsRandom | |
fsi 4216.fsx | |
fsi --define:DEBUG 4216.fsx | |
*) |