Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doomspork/mixology
A collection of tested Elixir examples solving various code challenges.
https://github.com/doomspork/mixology
elixir-lang examples
Last synced: 6 days ago
JSON representation
A collection of tested Elixir examples solving various code challenges.
- Host: GitHub
- URL: https://github.com/doomspork/mixology
- Owner: doomspork
- Created: 2018-04-21T04:59:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-21T05:59:21.000Z (over 6 years ago)
- Last Synced: 2024-11-05T14:54:43.349Z (about 2 months ago)
- Topics: elixir-lang, examples
- Language: Elixir
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mixology
This is _not_ a library, it is a collection of tested Elixir examples solving various code challenges.
### Examples
- [Fibonacci](https://github.com/doomspork/mixology/blob/master/lib/fibonacci.ex)
Given a integer _N_, print out _N_ steps of the Fibonacci sequence.
Testing is handled via doctests.
```elixir
iex> Fibonacci.run(12)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
```- [Word Count](https://github.com/doomspork/mixology/blob/master/lib/word_count.ex)
Count the occurrances of each word in the poem _Charge of the Light Brigade_.
Return each word and it's number of occurances, ordered from most frequent to least.
Testing is handled via doctests.
```elixir
iex> WordCount.run("./priv/charge_of_the_light_brigade.txt")
[{"the", 25}, {"of", 14}, {"and", 9}, {"them", 7}, {"six", 7},
{"hundred", 7}, {"to", 7}, {"they", 7}, {"cannon", 6}, {"rode", 6}]
```
- [Palindrome](https://github.com/doomspork/mixology/blob/master/lib/palindrome.ex)Provided with a string ("aabbc") print all possible palindrome premutations ("abcba", "bacab") to IO.
Leverages `ExUnit.CaptureIO` for tests.
```elixir
iex> Palindrome.run("aabbc")
bacab
abcba
:ok
```