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
| #upper triangular indices - iterates over upper triangular indices in a list of | |
| #indices. | |
| type uppertriangular; iterable; end | |
| Base.start(x::uppertriangular) = (1, 1) | |
| function Base.next(x::uppertriangular, state) | |
| (idx1, idx2) = state | |
| next1 = idx1 | |
| next2 = idx2 + 1 | |
| if next2 > length(x.iterable) |
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
| #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 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
| function column_sort_inplace!(matrix::AbstractMatrix, fn::Function) | |
| p = sort_columns_return_permutation(matrix, fn) | |
| #first, find the permutation of the matrix, reduced by rows. | |
| #create an array that signals the completion status of the process. | |
| completion = falses(length(p)) | |
| #store important indices | |
| current_root = 1 #root of the current cycle we're operating on. | |
| current_index = 1 #array index we're operating on. | |
| #next, allocate a short array that looks like the vector. |
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
| #bloom.jl - takes a file, reads binary data from the file and does whatever a | |
| #bloom filter would do. | |
| doc""" | |
| `BloomFilter{V}` | |
| defines a bloom filter over a value type V | |
| """ | |
| type BloomFilter{V} | |
| filter::BitVector | |
| hashes::Array{Function, 1} |
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
| #supson.jl | |
| type ツ; end | |
| _(::Type{ツ}) = ツ | |
| *(::Type{ツ}, ::Function) = ツ | |
| type ⎺; end | |
| Base.:\(::Type{⎺},::Type{ツ}) = ツ | |
| Base.:/(::Type{ツ},::Type{⎺}) = true | |
| ⎺\_(ツ)_/⎺ #==> 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
| function magicsum(arg){ | |
| var sumsofar = 0; | |
| var f; | |
| f = function(inner_arg){ | |
| if (inner_arg){ | |
| sumsofar += inner_arg; | |
| return f; | |
| } else { | |
| return sumsofar; |
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
| ## 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 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
| #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 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
| #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 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
| 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. |