left, right? head, tail? which one?
- Posted by Jeremy Cowgar <jeremy at co??ar.com> Apr 24, 2008
- 765 views
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:
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"
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 http://jeremy.cowgar.com