Re: left, right? head, tail? which one?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Cowgar wrote:
> 
> Ok... We have some functions that are dealing with sequences (can be applied
> to  sequences or "strings"). I am waffling between using left/right or
> head/tail
> naming conventions. What are your thoughts? Functions that use these are, for
> instance:
> 
> }}}
<eucode>
> left("John Doe", 4) -- "John"
> left({{1,2},{3,4},{5,6}}, 2) -- {{1,2},{3,4}}
> right("John Doe", 3) -- "Doe"
> tail("John Doe", 3) -- "Doe"
> pad_left("ABC", 6) -- "   ABC"
> pad_head("ABC", 6) -- "   ABC"
> pad_tail("ABC", 6) -- "ABC   "
> trim_tail("ABC   \r\n\t", 0) -- "ABC"
> trim_head("...ABC", '.') -- "ABC"
> trim_head("\r\t\nDEF ABC", "\tFD\n E") -- "ABC"
> </eucode>
{{{

> 
> I am wondering if the naming scheme of head/tail is better than left/right.
> When I think of head/tail I think of lists, which these functions do work on
> (I only gave the one example of left() as to not be too verbose in my
> example).
> Left/Right seem to apply more to strings (which these functions will work on
> as well, as you see).
> 
> Thoughts?
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>

Eu has no strings as distinct from lists of characters. The point of whether Eu
should or could have such a type has been hacked to death in the past. AFAIK, the
conclusion so far is that it might be nice, but requires a complete overhaul of
the type system implementation, and possibly slight loss in general performance.
No attempt has been made so far.

So, since we *only* have lists, head and tail make more sense for the very
reasons ou exposed.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu