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
import Base: map, push!, reduce, mapreduce | |
type Stream{T} | |
value::T | |
update_rule::Function | |
subscribers::Vector{Stream} | |
end | |
function Stream(startvalue, update_rule=self -> nothing, subscribers=[]) | |
T = typeof(startvalue) |
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 M | |
export @esc_none, @esc_all, @esc_args, @esc_args_impl | |
macro esc_none(x, y) | |
impl(x,y) | |
end | |
macro esc_all(x,y) | |
esc(impl(x,y)) | |
end |
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
using SIMD | |
Base.@pure simdwidth(::Type{T}) where {T} = Int(256/8/sizeof(T)) | |
@inline function median3(a,b,c) | |
max(min(a,b), min(c,max(a,b))) | |
end | |
@inline function median5(a,b,c,d,e) | |
# https://stackoverflow.com/questions/480960/code-to-calculate-median-of-five-in-c-sharp | |
f=max(min(a,b),min(c,d)) |
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
-- we can define functions that discard IO | |
io :: IO Int | |
io = print "wehaa" >> return 17 | |
supress :: IO Int -> Int | |
supress _ = 42 | |
supress io |
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
import Data.Map as Map | |
import Data.Map | |
import Control.Monad.State.Lazy | |
import Control.Monad | |
data Expr = ExInteger Integer | |
| ExSymbol String | |
| ExBinding String Expr deriving (Show) | |
type Errorful t = Either String t |
NewerOlder