Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
2371-Handle-special-cases-of-filter-fun-returns...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2371-Handle-special-cases-of-filter-fun-returns.patch of Package erlang
From 2e1660959c5a08888569ac468ca335a6d6ae2da9 Mon Sep 17 00:00:00 2001 From: Maria-12648430 <maria-12648430@gmx.net> Date: Mon, 26 Oct 2020 09:13:59 +0100 Subject: [PATCH 1/3] Handle special cases of filter fun returns If the filter function returns a single-item list or an empty list, it is treated the same way as the respective semantically equivalents of true and false. --- lib/stdlib/src/queue.erl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/stdlib/src/queue.erl b/lib/stdlib/src/queue.erl index 9fe3782f92..69ecfed94b 100644 --- a/lib/stdlib/src/queue.erl +++ b/lib/stdlib/src/queue.erl @@ -373,8 +373,12 @@ filter_f(Fun, [X|F]) -> case Fun(X) of true -> [X|filter_f(Fun, F)]; + [Y] -> + [Y|filter_f(Fun, F)]; false -> filter_f(Fun, F); + [] -> + filter_f(Fun, F); L when is_list(L) -> L++filter_f(Fun, F) end. @@ -388,8 +392,12 @@ filter_r(Fun, [X|R0]) -> case Fun(X) of true -> [X|R]; + [Y] -> + [Y|R]; false -> R; + [] -> + R; L when is_list(L) -> lists:reverse(L, R) end. -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor