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 Cuckoo | |
export @cuckoo | |
using Cassette | |
Cassette.@context Ctx | |
function _cuckoo(chicks::Dict, nest) | |
for (oldchicks, newchicks) ∈ chicks | |
@eval function Cassette.overdub(ctx::Ctx, |
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
""" | |
A macro `@replacerand` that replaces the value returned by a call to `rand` with something else. | |
""" | |
using Cassette | |
Cassette.@context ReplaceRand | |
Cassette.overdub(ctx::ReplaceRand, fn::typeof(rand), args...) = ctx.metadata(args...) |
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
# Based on https://gist.github.com/mbauman/d0c27f40e25393ef050b87b4bb6a69dc | |
using Cassette, ReplMaker | |
Cassette.@context RandAlwaysHalf | |
randreturnshalf(s, x) = x | |
function randreturnshalf(s, f, fx) | |
if f == rand | |
return randreturnshalf(s, one(typeof(fx)) / 2) |
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
using Base.Threads, Random | |
function run(;waittime=1.0e-3) | |
function calcsubset(N) | |
Random.seed!(0) | |
return sort(shuffle(collect(1:N))[1:Int(ceil(round(N / 3)))]) | |
end | |
# we know that only a sorted subset of rows need be iterated over for the first loop |
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 Functionals | |
abstract type Abstract end | |
type Functional <: Abstract | |
lower::Float64 | |
upper::Float64 | |
end | |
Functional(t::Float64) = Functional(0.0, 12.0 * t) |
NewerOlder