7

I am creating some software that has the concept of truncating a one-dimensional array from either the left or right end. I'm happy using the word truncate to describe lopping off the rightmost end of the array, but it doesn't feel right to use this word when removing array elements from the beginning.

I've considered left-truncate but that seems to have another meaning in statistics.

"I've (left-truncated) the array [1,2,3,4,5] and am left with [3,4,5]"

  • 2
    Trim is common to sound and video editting – Unrelated Apr 27 '17 at 21:15
  • 2
    Can you give references for your statement that left-truncate seems to have another meaning in statistics? – MikeRoger Apr 28 '17 at 9:15
8

Truncation can happen at either end:

Truncate

VERB

[WITH OBJECT]

often as adjective truncated

1 Shorten (something) by cutting off the top or the end.

‘a truncated cone shape’

‘discussion was truncated by the arrival of tea’

If you really wanted a different word, you might consider Prune or Trim, but they don't have the meaning of "at the beginning."

I suspect you'll need to specify which end you're truncating.

| improve this answer | |
  • Was going to upvote, but you have 666 rep. Sorry, I'm not going to ruin that. – pipe Apr 27 '17 at 22:21
  • @pipe -- I noticed that too -- I've taken a screenshot. 8^) – Roger Sinasohn Apr 27 '17 at 22:23
  • @jl6 "...off the top or the end." The top or the end in the array is the leftmost or the rightmost. So it's perfectly fine to use truncate for left or for right shortening of your array. I think in this case your understanding of the word is different from the meaning of the word (which happens to everyone with some words) - I would just adjust your understanding of what truncate means, given the above definition, and lose the hangup about only using it to refer to truncating when you remove from the end of something! – Gary Apr 27 '17 at 22:28
  • @Gary Who are you replying to here? The author of this answer clearly writes: Truncation can happen at either end, so it is obvious that he does not have a "hangup" about it. – pipe Apr 27 '17 at 22:30
  • @pipe Well I thought the @ that I started my comment with, made who I was writing to perfectly clear... That and the OP's original comment in their question: "but it doesn't feel right to use this word when removing array elements from the beginning." – Gary Apr 27 '17 at 22:30
5

In many libraries, this is called drop.

> 1 to 10 
res1: Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
> res1.drop(4) 
res2: Range = Range(5, 6, 7, 8, 9, 10)
| improve this answer | |
4

For the specific case of an array shift or slice may be what you want.

For arrays, a shift removes the first element of an array in Javascript and Ruby.

Slice means to return part of an array. It has no affinity toward the beginning or the end, so it may be suited for your purpose as long as you give the example. It typically expects a "start" index argument and an optional "end" argument index (end of array by default).

['a','b','c','d'].slice(1) => ['b','c','d']
['a','b','c','d'].slice(1,3) => ['b','c']

Slice is available in Javascript, Python, and Ruby (though my rep is too low to post links to these)

| improve this answer | |
2

For some reason, your title mentions the word opposite in meaning but the body of your question does not. What's up?

The meaning I get from "truncate" is to shorten an object by cutting part of it away from one or both of its ends.

Therefore, the word opposite in meaning would be to prepend or to postpend, depending upon which end one has in mind.

| improve this answer | |
  • I had the same thought. "Prepend" and "Postpend" are relatively recent terms though. I think the traditional terms are "prefix" and "append" – RaceYouAnytime Apr 27 '17 at 21:57
  • I too, thinking of prepend and prefix, looked up precate, but that's not a real word, I'm afraid. – Roger Sinasohn Apr 27 '17 at 22:20
2

If you are returning a new datastructure rather than modifying the source one in-place, then I have seen this operation be called Skip.

For example in .NET: https://msdn.microsoft.com/en-us/library/bb358985(v=vs.110).aspx

| improve this answer | |
0

Trim is what we call it over here where I live in the computer.

| improve this answer | |
  • 2
    Trim is usually applied to both sides, not just the beginning. – Glorfindel Apr 28 '17 at 10:50
  • so adapt, use 'left trim' – JMP Apr 29 '17 at 5:41
0

I think the proper word based on Latin roots should be "precise" as a verb. But, the adjective form and noun "precision" have hidden some of the root meaning it seems, so that many no longer could use "precise" (pronounced like 'pre-size') as a verb.

I would use precise myself and relish in the real core root meaning being resurrected, but one may compound pre and delete for a quick manifest understanding:

predelete or pre-delete

you could even pronounce it like 'pred-elite'.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.