Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #207

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/commands/gen_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ defmodule Commands.GeneralCommands do
def dehead(value) do
cond do
Functions.is_iterable(value) -> Stream.drop(value, 1) |> Stream.map(fn x -> x end)
true -> String.slice(to_string(value), 1..-1)
true -> String.slice(to_string(value), 1..-1//1)
end
end

def tail(value) do
cond do
Functions.is_iterable(value) -> hd(Enum.slice(Enum.to_list(value), -1..-1))
Functions.is_iterable(value) -> hd(Enum.slice(Enum.to_list(value), -1..-1//1))
is_integer(value) -> tail(Functions.to_non_number(value))
true -> String.slice(value, -1..-1)
true -> String.slice(value, -1..-1//1)
end
end

def detail(value) do
cond do
Functions.is_iterable(value) ->
value |> Enum.reverse |> tl |> Enum.reverse |> Stream.map(fn x -> x end)
true -> String.slice(to_string(value), 0..-2)
true -> String.slice(to_string(value), 0..-2//1)
end
end

Expand Down Expand Up @@ -98,7 +98,7 @@ defmodule Commands.GeneralCommands do
def count(value, element) when Functions.is_iterable(value), do: value |> Enum.count(fn x -> equals(x, element) end)
def count(value, element), do: count(value, element, 0)
defp count("", _, count), do: count
defp count(value, element, count), do: count(value |> String.slice(1..-1), element, count + Functions.to_number(value |> String.starts_with?(element)))
defp count(value, element, count), do: count(value |> String.slice(1..-1//1), element, count + Functions.to_number(value |> String.starts_with?(element)))

def strict_count(value, element) when not Functions.is_iterable(value) and not Functions.is_iterable(element), do: element |> Stream.map(fn x -> count(value, x) end)
def strict_count(value, element) when not Functions.is_iterable(value), do: count(value, element)
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/int_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ defmodule Commands.IntCommands do
defp from_roman_numeral("", number), do: number
defp from_roman_numeral(roman, number) do
[curr_number, curr_roman] = Enum.find(@roman_number_list, fn [_, y] -> String.starts_with?(roman, y) end)
from_roman_numeral(roman |> String.slice(String.length(curr_roman)..-1), number + curr_number)
from_roman_numeral(roman |> String.slice(String.length(curr_roman)..-1//1), number + curr_number)
end

def median([]), do: []
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/list_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ defmodule Commands.ListCommands do
Functions.is_iterable(count) -> take_split(value, count)
Functions.is_iterable(value) and count < 0 -> Stream.take(value, length(Enum.to_list(value)) + count) |> Stream.map(fn x -> x end)
Functions.is_iterable(value) -> Stream.take(value, Functions.to_number(count)) |> Stream.map(fn x -> x end)
true -> String.slice(to_string(value), 0..count - 1)
true -> String.slice(to_string(value), 0..count - 1//1)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/commands/str_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ defmodule Commands.StrCommands do
cond do
Regex.match?(~r/^[a-zA-Z]/, string) ->
matches = Regex.named_captures(~r/^(?<string>[a-zA-Z].+?)(?<remaining>(\.|!|\?|$).*)/s, string)
sentence_case(matches["remaining"], parsed <> String.capitalize(String.slice(matches["string"], 0..0)) <> String.slice(matches["string"], 1..-1))
sentence_case(matches["remaining"], parsed <> String.capitalize(String.slice(matches["string"], 0..0)) <> String.slice(matches["string"], 1..-1//1))
true ->
matches = Regex.named_captures(~r/^(?<string>.)(?<remaining>.*)/s, string)
sentence_case(matches["remaining"], parsed <> matches["string"])
Expand Down Expand Up @@ -236,7 +236,7 @@ defmodule Commands.StrCommands do
string = to_string(string)
cond do
String.contains?(string, "\n") -> Enum.join(intersected_mirror(String.split(string, "\n")), "\n")
true -> string <> (string |> String.reverse |> String.slice(1..-1) |> transliterate("<>{}()[]\\/", "><}{)(][/\\"))
true -> string <> (string |> String.reverse |> String.slice(1..-1//1) |> transliterate("<>{}()[]\\/", "><}{)(][/\\"))
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/interp/canvas.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ defmodule Interp.Canvas do

true ->
case List.last(parsed) do
[:code, prev_op] -> parse_directions(String.slice(string, 1..-1), Enum.slice(parsed, 0..-2) ++ [[:code, prev_op <> String.first(string)]])
_ -> parse_directions(String.slice(string, 1..-1), parsed ++ [[:code, String.first(string)]])
[:code, prev_op] -> parse_directions(String.slice(string, 1..-1//1), Enum.slice(parsed, 0..-2//1) ++ [[:code, prev_op <> String.first(string)]])
_ -> parse_directions(String.slice(string, 1..-1//1), parsed ++ [[:code, String.first(string)]])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/interp/commands/binary_interp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Interp.BinaryInterp do
alias Commands.IntCommands
alias Commands.GeneralCommands
import Interp.Functions
use Bitwise
import Bitwise

def interp_step(op, stack, environment) do
{b, stack, environment} = Stack.pop(stack, environment)
Expand Down
1 change: 0 additions & 1 deletion lib/interp/commands/nullary_interp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule Interp.NullaryInterp do
alias Commands.IntCommands
alias Commands.GeneralCommands
alias Reading.CodePage
use Bitwise

def interp_step(op, stack, environment) do
new_stack = case op do
Expand Down
1 change: 0 additions & 1 deletion lib/interp/commands/special_interp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ defmodule Interp.SpecialInterp do
alias Reading.Reader
alias Parsing.Parser
import Interp.Functions
use Bitwise

def interp_step(op, stack, environment) do
case op do
Expand Down
1 change: 0 additions & 1 deletion lib/interp/commands/subprogram_interp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule Interp.SubprogramInterp do
alias Commands.ListCommands
alias Commands.GeneralCommands
import Interp.Functions
use Bitwise

def interp_step(op, subcommands, stack, environment) do
case op do
Expand Down
1 change: 0 additions & 1 deletion lib/interp/commands/ternary_interp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ defmodule Interp.TernaryInterp do
alias Interp.Canvas
alias Commands.StrCommands
import Interp.Functions
use Bitwise

def interp_step(op, stack, environment) do
{c, stack, environment} = Stack.pop(stack, environment)
Expand Down
2 changes: 1 addition & 1 deletion lib/interp/commands/unary_interp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Interp.UnaryInterp do
alias Commands.GeneralCommands
alias Commands.MatrixCommands
import Interp.Functions
use Bitwise
import Bitwise

def interp_step(op, stack, environment) do
{a, stack, environment} = Stack.pop(stack, environment)
Expand Down
2 changes: 1 addition & 1 deletion lib/interp/functions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Interp.Functions do

if is_bitstring(value) and String.starts_with?(value, "-") do
try do
new_val = String.slice(value, 1..-1)
new_val = String.slice(value, 1..-1//1)
-to_number(new_val)
rescue
_ -> value
Expand Down
7 changes: 2 additions & 5 deletions lib/interp/interpreter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ defmodule Interp.Interpreter do
alias Interp.TernaryInterp
alias Interp.SpecialInterp
alias Interp.SubprogramInterp

use Bitwise


def interp_if_statement(if_statement, else_statement, stack, environment) do
{a, stack, environment} = Stack.pop(stack, environment)
Expand Down Expand Up @@ -58,7 +55,7 @@ defmodule Interp.Interpreter do
def interp_string(string, stack, environment) do
dissected_string = String.split(string, "ÿ")

{elements, stack, environment} = Enum.reduce(Enum.slice(dissected_string, 0..-2), {[], stack, environment},
{elements, stack, environment} = Enum.reduce(Enum.slice(dissected_string, 0..-2//1), {[], stack, environment},
fn (_, {acc, curr_stack, curr_env}) ->
case Stack.pop(curr_stack, curr_env) do
nil -> {acc, curr_stack, curr_env}
Expand All @@ -70,7 +67,7 @@ defmodule Interp.Interpreter do
elements == [] ->
{Stack.push(stack, string), environment}
true ->
string = Enum.zip(Enum.slice(dissected_string, 0..-2), Stream.cycle(elements)) ++ [{hd(Enum.slice(dissected_string, -1..-1)), ""}]
string = Enum.zip(Enum.slice(dissected_string, 0..-2//1), Stream.cycle(elements)) ++ [{hd(Enum.slice(dissected_string, -1..-1//1)), ""}]
|> Enum.reduce("", fn ({a, b}, acc) -> acc <> to_string(a) <> to_string(b) end)
{Stack.push(stack, string), environment}
end
Expand Down
4 changes: 2 additions & 2 deletions lib/reading/input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Reading.InputHandler do

defp parse_multiline_string(chars) do
cond do
String.ends_with?(chars, "\"\"\"") -> String.slice(chars, 0..-4)
String.ends_with?(chars, "\"\"\"") -> String.slice(chars, 0..-4//1)
true -> chars <> "\n" <> parse_multiline_string(String.trim_trailing(IO.read(:stdio, :line), "\n"))
:eof -> ""
end
Expand All @@ -26,7 +26,7 @@ defmodule Reading.InputHandler do
Globals.set(%{global_env | inputs: global_env.inputs ++ [result]})
result
String.starts_with?(input, "\"\"\"") ->
result = parse_multiline_string(String.slice(input, 3..-1))
result = parse_multiline_string(String.slice(input, 3..-1//1))
global_env = Globals.get()
Globals.set(%{global_env | inputs: global_env.inputs ++ [result]})
result
Expand Down
2 changes: 1 addition & 1 deletion lib/reading/reader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule Reading.Reader do
String.graphemes(File.read!(file_path))
:osabie ->
{_, file} = :file.open(file_path, [:read, :binary])
IO.binread(file, :all) |> :binary.bin_to_list |> Enum.map(fn x -> CodePage.osabie_to_utf8(x) end)
IO.binread(file, :eof) |> :binary.bin_to_list |> Enum.map(fn x -> CodePage.osabie_to_utf8(x) end)
end
end

Expand Down
22 changes: 11 additions & 11 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
%{
"certifi": {:hex, :certifi, "2.8.0", "d4fb0a6bb20b7c9c3643e22507e42f356ac090a1dcea9ab99e27e0376d695eba", [:rebar3], [], "hexpm", "6ac7efc1c6f8600b08d625292d4bbf584e14847ce1b6b5c44d983d273e1097ea"},
"excoveralls": {:hex, :excoveralls, "0.14.4", "295498f1ae47bdc6dce59af9a585c381e1aefc63298d48172efaaa90c3d251db", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e3ab02f2df4c1c7a519728a6f0a747e71d7d6e846020aae338173619217931c1"},
"hackney": {:hex, :hackney, "1.18.0", "c4443d960bb9fba6d01161d01cd81173089686717d9490e5d3606644c48d121f", [:rebar3], [{:certifi, "~>2.8.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "9afcda620704d720db8c6a3123e9848d09c87586dc1c10479c42627b905b5c5e"},
"httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"},
"excoveralls": {:hex, :excoveralls, "0.14.6", "610e921e25b180a8538229ef547957f7e04bd3d3e9a55c7c5b7d24354abbba70", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "0eceddaa9785cfcefbf3cd37812705f9d8ad34a758e513bb975b081dce4eb11e"},
"hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"},
"httpoison": {:hex, :httpoison, "1.8.2", "9eb9c63ae289296a544842ef816a85d881d4a31f518a0fec089aaa744beae290", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "2bb350d26972e30c96e2ca74a1aaf8293d61d0742ff17f01e0279fef11599921"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"},
"memoize": {:hex, :memoize, "1.4.0", "dce828382552a03d166b0793772514835ea079d74aa5f825dceb2827ad86cf13", [:mix], [], "hexpm", "c73d50feef0d44a9fa9a4d7e13ca53c367b0307aeb48204301d07a01a707b776"},
"memoize": {:hex, :memoize, "1.4.3", "ead4ba248291acbaecbfe7e68ed762d329dd9c29c727020c7393dda4060c4471", [:mix], [], "hexpm", "a75176b84b9ce92faaf567c82fcbc584ef95727e0827cb38606b0a197f7e47ef"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"mock": {:hex, :mock, "0.3.7", "75b3bbf1466d7e486ea2052a73c6e062c6256fb429d6797999ab02fa32f29e03", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "4da49a4609e41fd99b7836945c26f373623ea968cfb6282742bcb94440cf7e5c"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"mimerl": {:hex, :mimerl, "1.3.0", "d0cd9fc04b9061f82490f6581e0128379830e78535e017f7780f37fea7545726", [:rebar3], [], "hexpm", "a1e15a50d1887217de95f0b9b0793e32853f7c258a5cd227650889b38839fe9d"},
"mock": {:hex, :mock, "0.3.8", "7046a306b71db2488ef54395eeb74df0a7f335a7caca4a3d3875d1fc81c884dd", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "7fa82364c97617d79bb7d15571193fc0c4fe5afd0c932cef09426b3ee6fe2022"},
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
}
Loading