-
Notifications
You must be signed in to change notification settings - Fork 0
feat(naming): add support for roman numbers and jr suffix in extract_first_last_name/1 #2
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| elixir 1.16.1-otp-26 | ||
| erlang 26.2.1 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||||||||||||
| defmodule ExToolkit.Roman do | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And then we can replace |
||||||||||||||||||||||
| @valid_romans ["I", "V", "X", "L", "C", "D", "M"] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def is_valid_roman(string) do | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget documentation and unit tests ☝️ |
||||||||||||||||||||||
| string | ||||||||||||||||||||||
| |> String.upcase() | ||||||||||||||||||||||
| |> String.graphemes() | ||||||||||||||||||||||
| |> is_valid_roman(@valid_romans) | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not make sense since you are using directly |
||||||||||||||||||||||
| end | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| defp is_valid_roman([], _), do: true | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+11
to
+12
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| defp is_valid_roman([head | tail], valid_romans) do | ||||||||||||||||||||||
| if Enum.member?(@valid_romans, head) do | ||||||||||||||||||||||
| is_valid_roman(tail, valid_romans) | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| false | ||||||||||||||||||||||
| end | ||||||||||||||||||||||
| end | ||||||||||||||||||||||
|
Comment on lines
+13
to
+19
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And then you can just pipe it in the original case without the extra aux function 💡 |
||||||||||||||||||||||
| end | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.