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
(length(ARGS) < 4) && (println("error, insufficient arguments"); exit(1)) | |
infile, column, replace, outfile = ARGS | |
function replace_column(idx) | |
(idx == 0) && (println("column name doesn’t exist in the input file"); exit(1)) | |
mtx2 = copy(mtx) | |
mtx2[2:end,idx] = collect(Iterators.repeated(replace,size(mtx,1) - 1)) | |
mtx2 |
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
defmodule T do | |
def find_first_free(arr), do: find_first_free(arr, 0, []) | |
def find_first_free([], lowest_free, _leftovers), do: lowest_free | |
def find_first_free([head | tail], lowest_free, leftovers) do | |
if (lowest_free == head) do | |
find_first_free(tail, lowest_free + 1, leftovers) | |
else | |
find_first_free(tail, lowest_free, [head | leftovers]) | |
end | |
end |
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 simplify(e::Expr) | |
if e.head == :call | |
if e.args[1] == :+ | |
simplify_add(e) | |
end | |
end | |
end | |
function simplify_add(e::Expr) | |
terms = Dict{Symbol, Int}() |
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
#drivingtaxes.jl | |
using JSON | |
#make sure we have what we're looking for. | |
(length(ARGS) == 0) && throw(ErrorException("needs a file name")) | |
################################### | |
#rows iterator | |
type rows; tgt::Matrix; end | |
Base.start(r::rows) = 1 |
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
BootStrap: debootstrap | |
OSVersion: xenial | |
MirrorURL: http://us.archive.ubuntu.com/ubuntu | |
Include: bash python | |
%post | |
############################################################################## | |
## general system stuff | |
# respect license requirements |
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
defmodule Geoserver do | |
@moduledoc """ | |
Documentation for Geoserver. | |
""" | |
@doc """ | |
latlongdistance({ϕ1, λ1}, {ϕ2, λ2}) gives the distance, in kilometers, between | |
two points on the globe defined by {ϕ1, λ1}, {ϕ2, λ2}. Negative ϕ values are | |
in the southern hemisphere and negative λ are in the western hemisphere. |
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
#primefield.jl | |
type PrimeField{P} | |
intval::UInt64 | |
function PrimeField(n) | |
new(n % P) | |
end | |
end | |
Base.:+{P}(x::PrimeField{P}, y::PrimeField{P}) = PrimeField{P}(x.intval + y.intval) |
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
#elliptic.jl | |
#we'll make an "elliptic curve type" that is empty with no parameters. The advantage to this is that the parameter values | |
#take no memory in the point representation and are JITted in as assembler immediates. | |
type EllipticCurve{A, B}; end | |
#properties of the elliptic curves | |
discriminant{A,B}(E::Type{EllipticCurve{A,B}}) = -16 * (4*A^3 + 27*B^2) | |
issmooth(E) = discriminant(E) != 0 | |
haspoint{A,B}(E::Type{EllipticCurve{A,B}}, x, y) = y^2 == x^3 + A*x + B |
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
## binary_tree_print.jl | |
#binary tree defined as the following: | |
type Tree{T} | |
node::T | |
left::Union{Tree{T}, Void} | |
right::Union{Tree{T}, Void} | |
end |
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 magicsum(arg){ | |
var sumsofar = 0; | |
var f; | |
f = function(inner_arg){ | |
if (inner_arg){ | |
sumsofar += inner_arg; | |
return f; | |
} else { | |
return sumsofar; |