Solved: NoX Functional Program - Experts Exchange

Link to homeCreate AccountLog in.NET Programming

.NET Programming

--

Questions

--

Followers

Top Experts

Avatar of gudii9gudii9🇺🇸noX functional program Hi, http://codingbat.com/prob/p105967 I wrote my code as below and failing some tests public List<String> noX(List<String> strings) { strings.replaceAll(x -> ""); return strings; }

Select allOpen in new window

Expected Run noX(["ax", "bb", "cx"]) → ["a", "bb", "c"] ["", "", ""] X noX(["xxax", "xbxbx", "xxcx"]) → ["a", "bb", "c"] ["", "", ""] X noX(["x"]) → [""] [""] OK noX([""]) → [""] [""] OK noX([]) → [] [] OK noX(["the", "taxi"]) → ["the", "tai"] ["", ""] X noX(["the", "xxtxaxixxx"]) → ["the", "tai"] ["", ""] X noX(["this", "is", "the", "x"]) → ["this", "is", "the", ""] ["", "", "", ""] X other tests X

Select allOpen in new window

how to fix and improve my code, please advise

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

Avatar of ste5anste5an🇩🇪 Same as the other thread: Sort out your tags. Java or .NET? SOLUTIONAvatar of no bodyno bodyLink to homemembershipLog in or create a free account to see answer.Signing up is free and takes 30 seconds. No credit card required.Create AccountAvatar of gudii9gudii9🇺🇸

ASKER

how to do using lamda expression? Avatar of gudii9gudii9🇺🇸

ASKER

something like strings.replaceAll(x -> ""); Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Avatar of rrzrrz🇺🇸 Here is one way. import java.util.*; import java.util.stream.*; public class X { public static void main(String[] args) { List<String> list = Arrays.asList("xxax", "xbxbx", "xxcx", "zzz"); System.out.println(noX(list)); } public static List<String> noX(List<String> strings) { return strings.stream().map(s -> s.replaceAll("x","")).collect(Collectors.toList()); } }

Select allOpen in new window

Avatar of gudii9gudii9🇺🇸

ASKER

what is Colectors what is stream and collect methods here? please advise Avatar of rrzrrz🇺🇸 Discussion moved to https://www.experts-exchange.com/questions/29041669/Collectors-stream-collect-method.html  That way we all can be on the same page. Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

ASKER CERTIFIED SOLUTIONAvatar of rrzrrz🇺🇸Link to homemembershipLog in or create a free account to see answer.Signing up is free and takes 30 seconds. No credit card required.Create Account.NET Programming

.NET Programming

--

Questions

--

Followers

Top Experts

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Tag » Codingbat Nox Solution