mirror of
https://github.com/jbranchaud/til
synced 2026-01-08 09:38:04 +00:00
Add List Functions For A Module as an elixir til
This commit is contained in:
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
|
|||||||
warrant a full blog post. These are mostly things I learn by pairing with
|
warrant a full blog post. These are mostly things I learn by pairing with
|
||||||
smart people at [Hashrocket](http://hashrocket.com/).
|
smart people at [Hashrocket](http://hashrocket.com/).
|
||||||
|
|
||||||
_436 TILs and counting..._
|
_437 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -83,6 +83,7 @@ _436 TILs and counting..._
|
|||||||
|
|
||||||
- [Append To A Keyword List](elixir/append-to-a-keyword-list.md)
|
- [Append To A Keyword List](elixir/append-to-a-keyword-list.md)
|
||||||
- [Expose Internal Representation](elixir/expose-internal-representation.md)
|
- [Expose Internal Representation](elixir/expose-internal-representation.md)
|
||||||
|
- [List Functions For A Module](elixir/list-functions-for-a-module.md)
|
||||||
- [Replace Duplicates In A Keyword List](elixir/replace-duplicates-in-a-keyword-list.md)
|
- [Replace Duplicates In A Keyword List](elixir/replace-duplicates-in-a-keyword-list.md)
|
||||||
|
|
||||||
### Git
|
### Git
|
||||||
|
|||||||
25
elixir/list-functions-for-a-module.md
Normal file
25
elixir/list-functions-for-a-module.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# List Functions For A Module
|
||||||
|
|
||||||
|
During an `iex` session, I can do a little introspection on modules using
|
||||||
|
either the
|
||||||
|
[`__info__/1`](http://elixir-lang.org/docs/stable/elixir/Module.html#__info__/1)
|
||||||
|
function or Erlang's
|
||||||
|
[`module_info/0`](http://erlang.org/doc/man/erlang.html#module_info-0)
|
||||||
|
function. In particular, I can pass `:functions` to either one to get a list
|
||||||
|
of the functions for that module.
|
||||||
|
|
||||||
|
This is what the `__info__/1` looks like for the functions of the `List`
|
||||||
|
module:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
> List.__info__(:functions)
|
||||||
|
[delete: 2, delete_at: 2, duplicate: 2, first: 1,
|
||||||
|
flatten: 1, flatten: 2, foldl: 3, foldr: 3, insert_at: 3,
|
||||||
|
keydelete: 3, keyfind: 3, keyfind: 4, keymember?: 3,
|
||||||
|
keyreplace: 4, keysort: 2, keystore: 4, keytake: 3,
|
||||||
|
last: 1, replace_at: 3, to_atom: 1, to_existing_atom: 1,
|
||||||
|
to_float: 1, to_integer: 1, to_integer: 2, to_string: 1,
|
||||||
|
to_tuple: 1, update_at: 3, wrap: 1, zip: 1]
|
||||||
|
```
|
||||||
|
|
||||||
|
[source](http://stackoverflow.com/questions/28664119/in-elixir-is-there-any-way-to-get-a-module-to-list-its-functions)
|
||||||
Reference in New Issue
Block a user