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

Possible bug? #85

Open
dkuku opened this issue Oct 5, 2024 · 0 comments
Open

Possible bug? #85

dkuku opened this issue Oct 5, 2024 · 0 comments

Comments

@dkuku
Copy link
Contributor

dkuku commented Oct 5, 2024

Weird code - is it a bug?. This reduce does not use the accumulator just returns the last element from the list, thus the List.wrap is necessary.

            List.wrap(
              Enum.reduce(number_format.leading_digits_pattern, [], fn %{pattern: pattern}, _ ->
                pattern
              end)
            )

It should either be an empty list or [Enum.at(x, -1)] or I think Enum.map(x, &Map.get(&1, pattern))

Few examples from tests where the list contains multiple elements:

[                                                                                                                                             
  %{pattern: ~r/111|222|333/},                                       
  %{pattern: ~r/(?:111|222|333)1/},                                    
  %{pattern: ~r/(?:111|222|333)11/}                                    
]                                  
[                                  
  %{pattern: ~r/222|333/},
  %{pattern: ~r/2221|3332/},
  %{pattern: ~r/22212|3332/},
  %{pattern: ~r/222120|3332/}
]                                  
[%{pattern: ~r/[23]/}]
[%{pattern: ~r/077/}]
[%{pattern: ~r/[23]/}]
[                                  
  %{pattern: ~r/1(?:0|1[19]|[69]9|5[458])|[57]0/},                     
  %{pattern: ~r/1(?:0|1[19]|[69]9|5(?:44|59|8))|[57]0/}                
]                                  
[                                  
  %{pattern: ~r/1(?:[169][2-8]|[78]|5[1-4])|[68]0|[3-6][1-9][2-9]/},   
  %{pattern: ~r/1(?:[169][2-8]|[78]|5(?:[1-3]|4[56]))|[68]0|[3-6][1-9][2-9]/}
] 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant