Skip to content

Instantly share code, notes, and snippets.

View ewildgoose's full-sized avatar

Ed Wildgoose ewildgoose

  • Nippy Networks UK LLP
  • UK
View GitHub Profile
@ewildgoose
ewildgoose / gist:bedcefdb467b24ad2345
Created July 10, 2014 18:33
Trial Division Prime Generation in Elixir
defmodule Euler.Math.Prime do
def primes_up_to_slow(up_to) do
wheel2357
|> Stream.take_while( &( &1 <= up_to ) )
|> Enum.reduce(
[],
fn(x, primes) ->
limit=Float.ceil(:math.sqrt(x))
if(Euler.Math.Prime.test_prime_fast?(x, limit, Enum.reverse(primes))) do
defmodule BasicBench do
use Benchfella
@string_short 1..10 |> Enum.reduce( "", fn(_, acc) -> "a" <> acc end )
@string_100 1..100 |> Enum.reduce( "", fn(_, acc) -> "a" <> acc end )
@string_1000 1..1_000 |> Enum.reduce( "", fn(_, acc) -> "a" <> acc end )
@string_10k 1..10_000 |> Enum.reduce( "", fn(_, acc) -> "a" <> acc end )
@string_100k 1..10 |> Enum.reduce( "", fn(x, acc) -> @string_10k <> acc end )
# column :record_type, 2, :type => :integer
# column :sender, 5
# column :recipient, 5
# column :sequence, 5, :type => :integer
# column :tax_treatment, 1
# column :tax_rate, 32, :type => :integer
# spacer 13
# column :file_creation_date, 6, :type => :date, :format => '%y%m%d'
# column :file_transmission_date, 6, :type => :date, :format => '%y%m%d'
# column :cutoff_time, 12, :type => :string, :format => '%y%m%d%H%M%S'