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

Feat: remove_item_from_list #55

Closed
3 tasks done
Tracked by #57
nelsonic opened this issue Sep 13, 2023 · 4 comments
Closed
3 tasks done
Tracked by #57

Feat: remove_item_from_list #55

nelsonic opened this issue Sep 13, 2023 · 4 comments
Assignees
Labels
chore a tedious but necessary task often paying technical debt enhancement New feature or request help wanted Extra attention is needed priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Sep 13, 2023

Need this function and it doesn't appear to exists from my reading in the docs
for both https://hexdocs.pm/elixir/1.13.4/List.html and https://hexdocs.pm/elixir/1.13.4/Enum.html

We can implement it easily using a combination of functions.
But what I want is a one-line function that clearly says what it does and means I don't have to keep implementing this!

Todo

  • Write tests
  • Implement the function
  • Ship the package!
@nelsonic nelsonic added enhancement New feature or request help wanted Extra attention is needed chore a tedious but necessary task often paying technical debt priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies labels Sep 13, 2023
@nelsonic nelsonic self-assigned this Sep 13, 2023
@nelsonic nelsonic moved this to 🔖 Ready for Development in dwyl app kanban Sep 13, 2023
@nelsonic nelsonic moved this from 🔖 Ready for Development to 🏗 In progress in dwyl app kanban Sep 14, 2023
nelsonic added a commit that referenced this issue Sep 14, 2023
@nelsonic
Copy link
Member Author

Package published to https://hex.pm/packages/useful/1.13.0 📦 🚀
PR: #57

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in dwyl app kanban Sep 14, 2023
@nelsonic
Copy link
Member Author

Just remembered that all functions in the Elixir Standard library
that deal with "enumerables" (Enum, List, Map)
place the Enum first in the argument list for a function
so that they can be piped!

Right now with my first iteration of remove_item_from_list/2 with the argument order item, list (alphabetical),
we cannot pipe a list into the function ... 🙄

Going to update the argument order quickly. BRB. 🧑‍💻

@nelsonic nelsonic reopened this Sep 14, 2023
@nelsonic
Copy link
Member Author

To be clear: I prefer the arguments to be alphabetic for OCD reasons ... 🔤
But if we're building a library that is Useful to other people, 💭
.then it makes sense to be consistent with the standard library ... 👌

@nelsonic
Copy link
Member Author

Updated:

useful/lib/useful.ex

Lines 142 to 149 in a2c5135

def remove_item_from_list(list, item) do
if Enum.member?(list, item) do
i = Enum.find_index(list, fn it -> it == item end)
List.delete_at(list, i)
else
list
end
end

nelsonic added a commit to dwyl/mvp that referenced this issue Sep 14, 2023
nelsonic added a commit to dwyl/mvp that referenced this issue Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a tedious but necessary task often paying technical debt enhancement New feature or request help wanted Extra attention is needed priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: Done
Status: Done
Development

No branches or pull requests

1 participant