Original date:2015-07-28 13:43:22 Edited by: petelomax Subject: Re: better flatten()?

jimcbrown said...
DerekParnell said...

I don't know. I have not really had a need to use this function.

Why have the delim stuff in the first place? Euphoria generally doesn't follow the KISS principle, but I wonder if that's making the function overcomplicated. Does anybody use it?

I am beginning to think you might be quite right there, instead of flatten(s,delim) the programming construct to use should perhaps be join(flatten(s),delim), or often just join(s,delim).

I was also thinking that flatten() should either have a "check for string elements" option or a sister function, at least that was until I did a quick search...

I found the following uses of flatten() with a delimiter:

std\cmdline.e\build_commandline()    -- wants string handling, eg flatten({"del","filename"}," ") -> "del filename", rather than "d e l f i l e n a m e". 
redydemo\gui\objects\hypertext.e()   -- "" 
edita\eacons.ew (private routine)    -- "", for messagebox, eg flatten({"line1","line2","\n") -> "line1\nline2", rather than "l\ni\nn\ne\n1\nl\ni\nn\ne\n2" 
edita\eafext.ew ("")                 -- "" 
edita\eatabl.e ("")                  -- "" 

and only demo\net\pastey.ex without, which relies on \n being left in by read_lines() for something similar to eacons.ew above.

Surprisingly, all existing uses of flatten() that I could find were "sequence of string -> string", and all were really join() under a different name.


Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu