Logo

Programming-Idioms

From list a, create the text s specifying the contents of a, such that items are separated by delimiter d and items containg 1 or more spaces are quoted with quote character q.
Example: "A "," B"," C ",D,E,F
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
String s = a.stream()
    .map(x -> {
        if (!x.contains(" ")) return x;
        return q + x + q;
    })
    .reduce((x, y) -> x + d + y)
    .get();
classes
  a.Delimiter := d;
  a.QuoteChar := q;
  a.StrictDelimiter := False;
  a.AlwaysQuote := False;
  s := a.DelimitedText;
s = a.map{_1.include?(" ") ? q + _1 + q : _1 }.join(d)