From 1b355314f6d4a216ef3341e2adba19eaf2cad336 Mon Sep 17 00:00:00 2001 From: Norbert Melzer Date: Thu, 7 May 2015 20:54:11 +0200 Subject: [PATCH 1/3] consolidated new/1 and new/2 --- lib/array.ex | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/array.ex b/lib/array.ex index 4fc9639..0a62921 100644 --- a/lib/array.ex +++ b/lib/array.ex @@ -11,15 +11,6 @@ defmodule Array do @type opt :: {:fixed, boolean} | :fixed | {:default, any} | {:size, non_neg_integer} | non_neg_integer @type orddict :: [{index, element}] - @doc """ - Creates a new, extendible array with initial size zero. - The default value is the atom nil, not undefined. - """ - @spec new() :: t - def new() do - %Array{content: :array.new({:default, nil})} - end - @doc """ Creates a new fixed array according to the given options. By default, the array is extendible and has initial size zero. @@ -38,7 +29,7 @@ defmodule Array do * Sets the default value for the array to `value`. """ @spec new(opts) :: t - def new(options) do + def new(options \\ []) do if is_list(options) do %Array{content: :array.new([{:default, nil} | options])} else From 954d0a474e71c0ba53c1e364341484b0dc8efff3 Mon Sep 17 00:00:00 2001 From: Norbert Melzer Date: Thu, 7 May 2015 20:54:30 +0200 Subject: [PATCH 2/3] Consolidated from_list/1 and from_list/2 --- lib/array.ex | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/array.ex b/lib/array.ex index 0a62921..ba99f43 100644 --- a/lib/array.ex +++ b/lib/array.ex @@ -94,13 +94,6 @@ defmodule Array do def foldr(%Array{content: c}, acc, fun), do: :array.foldr(fun, acc, c) - @doc """ - Equivalent to `from_list(list, nil)`. - """ - @spec from_list(list) :: t - def from_list(list), - do: %Array{content: :array.from_list(list, nil)} - @doc """ Converts a list to an extendible array. `default` is used as the value for uninitialized entries of the array. @@ -108,7 +101,7 @@ defmodule Array do If `list` is not a proper list, the call raises `ArgumentError`. """ @spec from_list(list, any) :: t - def from_list(list, default), + def from_list(list, default \\ nil), do: %Array{content: :array.from_list(list, default)} @doc """ From cc86b9b366e24c24a943fa848d838a4fc8272249 Mon Sep 17 00:00:00 2001 From: Norbert Melzer Date: Thu, 7 May 2015 20:54:45 +0200 Subject: [PATCH 3/3] Consolidated from_orddict/1 and from_orddict/2 --- lib/array.ex | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/array.ex b/lib/array.ex index ba99f43..b6f46cd 100644 --- a/lib/array.ex +++ b/lib/array.ex @@ -104,13 +104,6 @@ defmodule Array do def from_list(list, default \\ nil), do: %Array{content: :array.from_list(list, default)} - @doc """ - Equivalent to `from_orddict(orddict, nil)`. - """ - @spec from_orddict(orddict) :: t - def from_orddict(orddict), - do: %Array{content: :array.from_orddict(orddict, nil)} - @doc """ Converts an ordered list of pairs `{index, value}` to a corresponding extendible array. `default` is used as the value for uninitialized entries of the array. @@ -119,7 +112,7 @@ defmodule Array do the call raises `ArgumentError`. """ @spec from_orddict(orddict, any) :: t - def from_orddict(orddict, default), + def from_orddict(orddict, default \\ nil), do: %Array{content: :array.from_orddict(orddict, default)} @doc """