exercism / elixir Goto Github PK
View Code? Open in Web Editor NEWExercism exercises in Elixir.
Home Page: https://exercism.org/tracks/elixir
License: MIT License
Exercism exercises in Elixir.
Home Page: https://exercism.org/tracks/elixir
License: MIT License
The problems api (x-api) now supports having exercises collected in a subdirectory
named exercises
.
That is to say that instead of having a mix of bin
, docs
, and individual exercises,
we can have bin
, docs
, and exercises
in the root of the repository, and all
the exercises collected in a subdirectory.
In other words, instead of this:
x{TRACK_ID}/
├── LICENSE
├── README.md
├── bin
│ └── fetch-configlet
├── bowling
│ ├── bowling_test.ext
│ └── example.ext
├── clock
│ ├── clock_test.ext
│ └── example.ext
├── config.json
└── docs
│ ├── ABOUT.md
│ └── img
... etc
we can have something like this:
x{TRACK_ID}/
├── LICENSE
├── README.md
├── bin
│ └── fetch-configlet
├── config.json
├── docs
│ ├── ABOUT.md
│ └── img
├── exercises
│ ├── bowling
│ │ ├── bowling_test.ext
│ │ └── example.ext
│ └── clock
│ ├── clock_test.ext
│ └── example.ext
... etc
This has already been deployed to production, so it's safe to make this change whenever you have time.
There was some confusion in this exercise due to the ambiguous use of the term consecutive in the README. This could be taken to mean contiguous, as in consecutive by position, or as in consecutive numerically. The the README has been fixed (exercism/problem-specifications#200).
Please verify that the exercise is implemented in this track correctly (that it finds series of contiguous numbers, not series of numbers that follow each other consecutively).
If it helps, the canonical inputs/outputs for the exercise can be found here:
https://github.com/exercism/x-common/blob/master/largest-series-product.json
If everything is fine, go ahead and just close this issue. If there's something to be done, then please describe the steps needed in order to close the issue.
The old help site was deprecated in December 2015. We now have content that is displayed on the main exercism.io website, under each individual language on http://exercism.io/languages.
The content itself is maintained along with the language track itself, under the docs/
directory.
We decided on this approach since the maintainers of each individual language track are in the best position to review documentation about the language itself or the language track on Exercism.
Please verify that nothing in docs/
refers to the help.exercism.io site. It should instead point to http://exercism.io/languages/:track_id (at the moment the various tabs are not linkable, unfortunately, we may need to reorganize the pages in order to fix that).
Also, some language tracks reference help.exercism.io
in the SETUP.md file, which gets included into the README of every single exercise in the track.
We may also have referenced non-track-specific content that lived on help.exercism.io. This content has probably been migrated to the Contributing Guide of the x-common repository. If it has not been migrated, it would be a great help if you opened an issue in x-common so that we can remedy the situation. If possible, please link to the old article in the deprecated help repository.
If nothing in this repository references help.exercism.io, then this can safely be closed.
The information in here should not be about learning Elixir but rather links to documentation, community, etc.
The test here:
https://github.com/exercism/xelixir/blob/master/exercises/accumulate/accumulate_test.exs#L35
Looks like its attempting to check that the accumulate/2
function will continue mapping if it encounters a list as one of the items in the list. This however is not true since the 2nd level of lists is just created in the anonymous function.
The test IMO should be more like:
chars = ~w(a b c)
nums = ~w(1 2 3)
list = for c <- chars, num <- nums, do: c <> num
expected = [["A1", "A2", "A3"], ["B1", "B2", "B3"], ["C1", "C2", "C3"]]
assert Accumulate.accumulate(chars, &String.upcase/1) == expected
@JEG2 I belive you submitted this exercism
Copied from exercism/exercism#156 /cc @rubysolo @pminten
This is a placeholder issue for keeping track of porting assignments to Elixir, or noting why they may not be applicable.
not applicable
Hello, as part of exercism/problem-specifications#198 we'd like to make the sum of multiples exercise less confusing. Currently, the README specifies that if no multiples are given it should default to 3 and 5.
We'd like to remove this default, so that a list of multiples will always be specified by the caller. This makes the behavior explicit, avoiding surprising behavior and simplifying the problem.
Please make sure this track's tests for the sum-of-multiples problem do not expect such a default. Any tests that want to test behavior for multiples of [3, 5] should explicitly pass [3, 5] as the list of multiples.
After all tracks have completed this change, then exercism/problem-specifications#209 can be merged to remove the defaults from the README.
The reason we'd like this change to happen before changing the README is that it was very confusing for students to figure out the default behavior. It wasn't clear from simply looking at the tests that the default should be 3 and 5, as seen in exercism/exercism#2654, so some had to resort to looking at the example solutions (which aren't served by exercism fetch
, so they have to find it on GitHub). It was added to the README to fix this confusion, but now we'd like to be explicit so we can remove the default line from the README.
You can find the common test data at https://github.com/exercism/x-common/blob/master/sum-of-multiples.json, in case that is helpful.
Posted by @meantime in exercism.io:
The instructions for the Bob assignment say:
He answers 'Whoa, chill out!' if you yell at him.
However, some of the language test cases check for "Woah" (note that the 'h' has moved to the end)
The difference exists in Objective-C, PERL5, OCaml, Elixir, and Clojure
A duration of a gigasecond should be measured in seconds, not
days.
The gigasecond
problem has been implemented in a number of languages,
and this issue has been generated for each of these language tracks.
This may already be fixed in this track, if so, please make a note of it
and close the issue.
There has been some discussion about whether or not gigaseconds should
take daylight savings time into account, and the conclusion was "no", since
not all locations observe daylight savings time.
Placeholder to update the code to Elixir 1.0 once it is release.
The metadata for this problem has been simplified, and it might be worth changing the test suite and example so that theres no mention of RNA or uracil.
I've also changed the API of the problem in Ruby so that there is no error checking in the object itself, only in the factory that creates it: https://github.com/exercism/xruby/blob/master/nucleotide-count/example.rb#L2-L8
I don't know if this is relevant or idiomatic in Elixir.
I'm currently making my way through the elixir track slowly, but some of the exercises (so far, as a newcomer) seem to occur later or earlier than I would expect.
A couple of examples:
Exercise 5: The list-ops exercise, using core language features to re-implement reduce, append, filter, count, concat, and map occurs before:
Exercise 12: Accumulate (Given a list and a function, apply the function to each list item and replace it with the function's return value.
)
Exercise 10: Nucleotide-count (Counting occurrences of a character in a character list, raising exceptions based on invalid arguments, creating histogram of preset characters), occurs before
Exercise 11: rna-transcription (simple letter substitution).
I didn't see any open (or closed) issues about this, so thought I'd throw this out there for discussion. Thanks!
Given that there is a set progression of exercises there is some tendency in the users to almost "inherit" guidance from previous exercises if the current exercise appears to be an expansion of the previous.
For example, the previous exercise "list-ops" had the explicit instruction:
"Implement a series of basic list operations, without using existing functions."
When the next exercise is another list operations (specifically, sublist) there is some confusion as to whether there is an expectation for the users to write all methods from first principles or use the built-in list operators.
Hello!
The Set
module was deprecated in 1.2, and the behaviour has since been removed. It's not possible to directly port the changes to the MapSet
replacement as it's a single data structure implementation rather than a behaviour with a default implementation.
This exercise needs to be removed, or entirely re-written. :(
I notice there are other open issues for this exercise. #198 #180 #121
@pminten brought up a very good point about the API of meetup being
pretty terrible (See exercism/exercism#950).
If the meetup problem has not already been fixed in this track, we should
improve the test suite and example code to give the API a better design.
We should have separate tests for:
If the test suite for binary has test cases that cover these edge cases, this issue can safely be closed.
There's one exercise (OCR numbers) where trailing whitespace is necessary for the test data, but (a) I don't know if that exercise is implemented, and (b) maybe we could put the actual test data in external files with a different file extension.
If we make sure not to screw up any exercises, though, we could fail the build if there's trailing whitespace by sticking this in the travis file.
- "! git grep ' $' -- \\*.exs"
I find it a bit strange to have only one test for bob which is running when you run the tests. And the exercise can be completed with the default case of the condition.
Is this on purpose?
I made a really stupid choice a while back to commit the cross-compiled
binaries for configlet (the tool that sanity-checks the config.json
against the implemented problems) into the repository itself.
Those binaries are HUGE, and every time they change the entire 4 or 5 megs get
recommitted. This means that cloning the repository takes a ridiculously long
time.
I've added a script that can be run on travis to grab the latest release from
the configlet repository (bin/fetch-configlet), and travis is set up to run
this now instead of using the committed binary.
I would really like to thoroughly delete the binaries from the entire git
history, but this will break all the existing clones and forks.
The commands I would run are:
# ensure this happens on an up-to-date master
git checkout master && git fetch origin && git reset --hard origin/master
# delete from history
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch bin/configlet-*' --prune-empty
# clean up
rm -rf .git/refs/original/
git reflog expire --all
git gc --aggressive --prune
# push up the new master, force override existing master branch
git push -fu origin master
If we do this everyone who has a fork will need to make sure that their master
is reset to the new upstream master:
git checkout master
git fetch upstream master
git reset --hard upstream/master
git push -fu origin master
We can at-mention (@) all the contributors and everyone who has a fork here in this
issue if we decide to do it.
The important question though, is: Is it worth doing?
Do you have any other suggestions of how to make sure this doesn't confuse people and break their
repository if we do proceed with this change?
Please check if there's a test that states that a triangle with sides 2, 4, 2 is invalid. The triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side. If this doesn't affect this track, go ahead and just close the issue.
While doing the word-count exercise I noticed that all of the tests would fail with a ** (UndefinedFunctionError) undefined function: HashDict.new/1
message. I supposed this worked at some point. My Elixir version is 0.13.2.
My solution was to change every HashDict.new [{"foo", 1}]
type line to Enum.into [{"foo", 1}], HashDict.new
and then tests would run for the exercise. I'm new to Elixir so I don't know if there's a better way of setting up the test expectations.
There is an interesting edge case in the meetup problem:
some months have five Mondays.
March of 2015 has five Mondays (the fifth being March 30th), whereas
February of 2015 does not, and so should produce an error.
Thanks, @JKesMc9tqIQe9M for pointing out the edge case.
See exercism.io#2142.
I can't remember the history of this, but we ended up with a weird non-biological thing in the RNA transcription exercise, where some test suites also have tests for transcribing from RNA back to DNA. This makes no sense.
If this track does have tests for the reverse transcription, we should remove them, and also simplify the reference solution to match.
If this track doesn't have any tests for RNA->DNA transcription, then this issue can be closed.
The word multibillionaire is too long for the scrabble board. Oxyphenbutazone, on the other hand, is legal.
Please verify that there is no test for multibillionaire in the scrabble-score in this track. If the word is included in the test data, then it should be replaced with oxyphenbutazone. Remember to check the case (if the original is uppercase, then the replacement also should be).
If multibillionaire isn't used, then this issue can safely be closed.
This happened a while back, and it was for really weird legacy reasons.
I've since fixed the underlying issues that caused the problem, but for consistency
it would be nice to rename point-mutation to hamming, so that all the tracks are using
the same exercise name.
Once the problem has been renamed, I can run a script on the website to point people's
existing point-mutations solutions to the new hamming exercise so that they'll be able
to review solutions to hamming, and people who solve the new hamming exercise can see
all the old ones.
exercism fetch elixir hello-world
command is not working. It returns 404 for me.
Please fix it.
Per the 1.2 changelog https://github.com/elixir-lang/elixir/blob/v1.2.0/CHANGELOG.md
atbash-cipher/example.exs
28: Dict.get(@key, character, character)
etl/etl.exs
10: @spec transform(Dict.t) :: map()
etl/example.exs
12: |> Dict.to_list
forth/example.exs
98: do_eval(%{s | defs: Dict.put(s.defs, w, ws), input: r})
minesweeper/example.exs
34: Dict.update(acc, c1, 1, &(&1+1))
nucleotide-count/dna.exs
29: @spec histogram([char]) :: Dict.t
palindrome-products/example.exs
22: Dict.update(dict, product,
palindrome-products/palindrome_products_test.exs
16: assert (palindromes |> Dict.keys |> Enum.sort |> List.last) == 9
23: assert (palindromes |> Dict.keys |> Enum.sort |> List.last) == 9009
30: assert (palindromes |> Dict.keys |> Enum.sort |> hd) == 121
37: assert (palindromes |> Dict.keys |> Enum.sort |> List.last) == 906609
44: assert (palindromes |> Dict.keys |> Enum.sort |> hd) == 10201
parallel-letter-frequency/example.exs
33: |> Enum.reduce(%{}, fn c, acc -> Dict.update(acc, c, 1, &(&1+1)) end)
38: Dict.merge(acc, d, fn _, a, b -> a+b end)
parallel-letter-frequency/frequency.exs
9: @spec frequency([String.t], pos_integer) :: Dict.t
test/test_helper.exs
6:|> Dict.get("problems")
word-count/example.exs
21: Dict.update(counts, word, 1, &(&1 + 1))
The stub file only does provide a Queens.new/1
which has @spec new(nil | list)
, while the tests do call it either without any arguments or with two seperate arguments but not a list.
I was just looking through the tests for another thing I'm doing, and I saw that we're still using HashSet
in allergies
here: https://github.com/exercism/xelixir/blob/master/exercises/allergies/allergies_test.exs#L75
That's now deprecated, so we'll have to update it to use MapSet. I'll probably take care of that today, but I wanted to write it down so I don't forget (or so someone else can take care of it).
I really like the typespecs which are provided with the module skeletons.
But sometimes they don't get updated in the example and/or the skelleton when tests are updated to expect new types, also I do often forget to update them when I catch for the newest version of the tests.
Is there an easy and hassle free way to actually do a check against the specs without wrapping everything into a mix-project?
And if so, could this be used in CI also?
Can we mention it in the README as a part of running the tests?
I'm afraid we've swapped on bug for another. Using atoms for the grade levels has the unfortunate side effect that sorting is done like a string rather than a number. That means :grade_11
will come before :grade_2
. See parkerl@ce61f42
This fails:
1) test sort school by grade and by student name (SchoolTest)
grade_school_test.exs:55
Assertion with == failed
code: expected == actual
lhs: [grade_3: ["Kyle"], grade_4: ["Bart", "Christopher", "Jennifer"], grade_6: ["Kareem"], grade_11: ["John"]]
rhs: [grade_11: ["John"], grade_3: ["Kyle"], grade_4: ["Bart", "Christopher", "Jennifer"], grade_6: ["Kareem"]]
stacktrace:
grade_school_test.exs:72
My thought would be to revert to the original implementation but have sort
return a list of two tuples with the grade and names, [{1, ["John"]}]
. This would leave most of the original exercise intact and only change the api of the function with the bug.
I'm sorry I was too slow to get this review prepared before the PR was merged. My bad.
\cc @bordeltabernacle
From issue exercism/exercism#1867
Wikipedia says the Hamming distance is not defined for strings of different length.
I am not saying the problems cannot be different, but for such a well-defined concept it would make sense to stick to one definition, especially when the READMEs provide so little information about what is expected from the implementation.
Let's clean this up so that we're using the official definition.
Would it be possible to run doctest's along the regular ones, but when exercises are pulled from exercism.io? (as opposed to working with mix within this project)
Currently, the mix setup from the root of this project isn't added to exercism's elixir folder, and executing e.g. elixir phone_number_test.exs
executes only the ones in the test file.
The only workaround I have for now is:
elixirc phone_number.exs
doctest Phone
beneath use ExUnit.Case, async: true
in test fileelixir phone_number_test.exs
runs the doctest as well.The only problem with this is that one needs to execute the compile step for every change to the main module. I guess this could be made into a small script, e.g run_tests.sh
.
elixirc main_module.exs && elixir test_module.exs
Since I'm new to Elixir, I don't know if this would work in all cases (Windows, ...?). What do you think? P.S. I'd be glad to PR this if above suggestion is on the right track.
Related issues: #23
Less, but still related issues: #96, #47
The palindrome instruction in the README seems to fall short compares to instructions from other exercises I've seen so far.
9 => [[1, 9], [3, 3]]
, and that all single digits were considered palindrome products. Perhaps a link to the wiki page would be good?Dict.keys
on my results.Just wanted to drop a note in case someone else agrees and it's worthwhile. I could probably do it sometimes in the future when I'm not too busy too.
Thanks!
See exercism/docs#54 for details.
Currently the link gives you a 404. The right link is probably this one
The contents of the SETUP.md file gets included in
the README.md that gets delivered when a user runs the exercism fetch
command from their terminal.
At the very minimum, it should contain a link to the relevant
language-specific documentation on
help.exercism.io.
It would also be useful to explain in a generic way how to run the tests.
Remember that this file will be included with all the problems, so it gets
confusing if we refer to specific problems or files.
Some languages have very particular needs in terms of the solution: nested
directories, specific files, etc. If this is the case here, then it would be
useful to explain what is expected.
Thanks, @tejasbubane for suggesting that we add this documentation everywhere.
See exercism.io#2198.
Consider add one more test case for Prime Factors
test "10000000055" do
assert PrimeFactors.factors_for(10000000055) == [5, 2000000011]
end
With my first iteration, it took 44189.1ms to pass this test. So need to tweak the solution to get this test pass in a decent time. I think it would serve a good test case to make your solution more optimized.
We recently rewrote the test suite for Custom Set. Since this track implements Custom Set, please take a look at the new custom_set.json file and see if your track should update its implementation or tests.
The new test suite reorders tests so that students can get to green quickly. It also reduces the number of tests so that students can focus on solving the interesting edge cases.
More details on this change are available in the pull request
See issue exercism/exercism#2092 for an overview of operation welcome contributors.
Provide instructions on how to contribute patches to the exercism test suites
and examples: dependencies, running the tests, what gets tested on Travis-CI,
etc.
The contributing document
in the x-api repository describes how all the language tracks are put
together, as well as details about the common metadata, and high-level
information about contributing to existing problems, or adding new problems.
The README here should be language-specific, and can point to the contributing
guide for more context.
From the OpenHatch guide:
Here are common elements of setting up a development environment you’ll want your guide to address:
Preparing their computer
Make sure they’re familiar with their operating system’s tools, such as the terminal/command prompt. You can do this by linking to a tutorial and asking contributors to make sure they understand it. There are usually great tutorials already out there - OpenHatch’s command line tutorial can be found here.
If contributors need to set up a virtual environment, access a virtual machine, or download a specific development kit, give them instructions on how to do so.
List any dependencies needed to run your project, and how to install them. If there are good installation guides for those dependencies, link to them.Downloading the source
Give detailed instructions on how to download the source of the project, including common missteps or obstacles.How to view/test changes
Give instructions on how to view and test the changes they’ve made. This may vary depending on what they’ve changed, but do your best to cover common changes. This can be as simple as viewing an html document in a browser, but may be more complicated.Installation will often differ depending on the operating system of the contributor. You will probably need to create separate instructions in various parts of your guide for Windows, Mac and Linux users. If you only want to support development on a single operating system, make sure that is clear to users, ideally in the top-level documentation.
Right now all of the icons used for the language tracks (which can be seen at http://exercism.io/languages) are stored in the exercism/exercism.io repository in public/img/tracks/
. It would make a lot more sense to keep these images along with all of the other language-specific stuff in each individual language track repository.
There's a pull request that is adding support for serving up the track icon from the x-api, which deals with language-specific stuff.
In order to support this change, each track will need to
img/
at the root of this repository if it doesn't already exist, thenimg/
directory, and importantlyicon.png
In other words, at the end of it you should have the following file:
./img/icon.png
See exercism/exercism#2925 for more details.
We should update our target version to Elixir 1.2.
#We are getting quite a few of these in the examples after the 1.2 upgrade
warning: you are piping into a function call without parentheses, which may be ambiguous. Please wrap the function you are piping into in parentheses. For example:
foo 1 |> bar 2 |> baz 3
Should be written as:
foo(1) |> bar(2) |> baz(3)
In order to reduce the amount of code required to pass incremental tests (assuming that users pass tests starting from the top), the order of the tests was modified slightly.
Since this track implements Custom Set, please take a look at the new custom-set.json file and see if your track should update its tests.
If you do need to update your tests, please refer to this issue in your PR. That helps us see which tracks still need to update their tests.
If your track is already up to date, go ahead and close this issue.
More details on this change are available in exercism/problem-specifications#257.
According to the typespec given in the exercise-stub, I'd expect Accumulate.accumulate %{foo: :bar}, &(&1)
beeing a valid call of the function, but such is not caovered by the tests, as well as the example implementation does as well only handle lists.
So either the @spec
is wrong and should be changed towards a more proper @spec accumulate(list, (any -> any)) :: list
or the example is wrong and another clause should be added (def accumulate(anything), fun) when not is_list(anything), do: anything |> Enum.into([]) |> accumulate(fun)
) as well as some tests that do test some other Enumable.t
s that are not lists.
the def exception
functions seem like they should be def message
functions, which is the function used in the example
I dont know a ton on the working of defining custom errors in elixir so I cant give much more information.
The conclusion in the subject is from a very brief look at the code.
In general, you can't search a linked list, in a way that is more efficient than a linear search, due to its nature.
To access the element in the middle, you have to iterate the first half of the list completely, while dooing this recursively, you might even read over the searched element multiple times.
Also when splitting the list you do again fly over the first half (even doing a copy when the element is there!)
I already had a similar discussion in a project which aims on implementing some prominent CS datastructures and algorithms over it, perhaps you want to take a read at sashaafm/exads#14 and then deprecate/remove this exercise from this track.
Per https://github.com/elixir-lang/elixir/blob/v1.2.0/CHANGELOG.md
allergies/allergies_test.exs
77: set = Enum.into(list, HashSet.new)
79: |> Enum.into(HashSet.new)
80: |> Set.equal?(set)
82: "Expected a set with: #{inspect to_contain} got #{inspect set |> Set.to_list}"
custom-set/custom_set.exs
1:defmodule CustomSet do
2: # This lets the compiler check that all Set callback functions have been
4: @behaviour Set
custom-set/custom_set_test.exs
10:defmodule CustomSetTest do
13: # Tip: to make your set work with the Set module be sure that your set value
14: # is a tuple with as first element `CustomSet`. A record with tag `CustomSet`
19: assert Set.equal?(Set.delete(CustomSet.new([3,2,1]), 2), CustomSet.new([1,3]))
20: assert Set.equal?(Set.delete(CustomSet.new([3,2,1]), 4), CustomSet.new([1,2,3]))
21: assert Set.equal?(Set.delete(CustomSet.new([3,2,1]), 2.0), CustomSet.new([1,2,3]))
26: assert Set.equal?(
27: Set.difference(CustomSet.new([1,2,3]), CustomSet.new([2,4])),
28: CustomSet.new([1,3]))
29: assert Set.equal?(
30: Set.difference(CustomSet.new([1,2.0,3]), CustomSet.new([2,4])),
31: CustomSet.new([1,2.0,3]))
36: assert Set.disjoint?(CustomSet.new([1,2]), CustomSet.new([3,4]))
37: refute Set.disjoint?(CustomSet.new([1,2]), CustomSet.new([2,3]))
38: assert Set.disjoint?(CustomSet.new([1.0,2.0]), CustomSet.new([2,3]))
39: assert Set.disjoint?(CustomSet.new, CustomSet.new)
44: assert Set.equal?(Set.empty(CustomSet.new([1,2])), CustomSet.new)
45: assert Set.equal?(Set.empty(CustomSet.new), CustomSet.new)
50: assert Set.equal?(
51: Set.intersection(CustomSet.new([:a, :b, :c]), CustomSet.new([:a, :c, :d])),
52: CustomSet.new([:a, :c]))
53: assert Set.equal?(
54: Set.intersection(CustomSet.new([1, 2, 3]), CustomSet.new([1.0, 2.0, 3])),
55: CustomSet.new([3]))
60: assert Set.member?(CustomSet.new([1,2,3]), 2)
61: assert Set.member?(CustomSet.new(1..3), 2)
62: refute Set.member?(CustomSet.new(1..3), 2.0)
63: refute Set.member?(CustomSet.new(1..3), 4)
68: assert Set.equal?(
69: Set.put(CustomSet.new([1,2,4]), 3),
70: CustomSet.new([1,2,3,4]))
71: assert Set.equal?(
72: Set.put(CustomSet.new([1,2,3]), 3),
73: CustomSet.new([1,2,3]))
74: assert Set.equal?(
75: Set.put(CustomSet.new([1,2,3]), 3.0),
76: CustomSet.new([1,2,3,3.0]))
81: assert Set.size(CustomSet.new) == 0
82: assert Set.size(CustomSet.new([1,2,3])) == 3
83: assert Set.size(CustomSet.new([1,2,3,2])) == 3
88: assert Set.subset?(CustomSet.new([1,2,3]), CustomSet.new([1,2,3]))
89: assert Set.subset?(CustomSet.new([1,2,3]), CustomSet.new([4,1,2,3]))
90: refute Set.subset?(CustomSet.new([1,2,3]), CustomSet.new([4,1,3]))
91: refute Set.subset?(CustomSet.new([1,2,3.0]), CustomSet.new([1,2,3,4]))
92: assert Set.subset?(CustomSet.new, CustomSet.new([4,1,3]))
93: assert Set.subset?(CustomSet.new, CustomSet.new)
98: assert Enum.sort(Set.to_list(CustomSet.new)) == []
99: assert Enum.sort(Set.to_list(CustomSet.new([3,1,2]))) == [1,2,3]
100: assert Enum.sort(Set.to_list(CustomSet.new([3,1,2,1]))) == [1,2,3]
105: assert Set.equal?(
106: CustomSet.union(CustomSet.new([1,3]), CustomSet.new([2])),
107: CustomSet.new([3,2,1]))
108: assert Set.equal?(
109: CustomSet.union(CustomSet.new([1,3]), CustomSet.new([2,3.0])),
110: CustomSet.new([3.0,3,2,1]))
111: assert Set.equal?(
112: CustomSet.union(CustomSet.new([1,3]), CustomSet.new),
113: CustomSet.new([3,1]))
114: assert Set.equal?(
115: CustomSet.union(CustomSet.new, CustomSet.new([2])),
116: CustomSet.new([2]))
117: assert Set.equal?(
118: CustomSet.union(CustomSet.new, CustomSet.new),
119: CustomSet.new([]))
124: assert inspect(CustomSet.new) == "%CustomSet{list: []}"
125: assert inspect(CustomSet.new([1,3,2])) == "%CustomSet{list: [1, 2, 3]}"
128: assert inspect(CustomSet.new(["A",:b,?C])) == "%CustomSet{list: [67, :b, \"A\"]}"
Zipper.up
is never used in the zipper_text.exs
but the stub for it in the example is still there. I can write a couple tests for it and send those in, unless somebody else wants to that knows more about the exercises than me
The tests do check for Inspect
as foolows:
test "inspect" do
assert inspect(CustomSet.new) == "%CustomSet{list: []}"
assert inspect(CustomSet.new([1,3,2])) == "%CustomSet{list: [1, 2, 3]}"
assert inspect(CustomSet.new(["A",:b,?C])) == "%CustomSet{list: [67, :b, \"A\"]}"
end
While the example implementation does implement Inspect
as follows:
def inspect(s, opts) do
concat ["#<CustomSet ", to_doc(CustomSet.to_list(s), opts), ">"]
end
Before commit 9222be9 the example and the test matched.
Hi,
Without proper mix.exs
files the tests aren't runnable for the exercises.
Or I'm wrong?
Cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.