English Language & Usage Asked by jl6 on April 4, 2021
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]”
Truncation can happen at either end:
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.
Answered by Roger Sinasohn on April 4, 2021
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.
Answered by Senex Ægypti Parvi on April 4, 2021
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)
Answered by valbaca on April 4, 2021
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
Answered by dangph on April 4, 2021
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)
Answered by Malvolio on April 4, 2021
Trim
is what we call it over here where I live in the computer.
Answered by J. Doe on April 4, 2021
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'.
Answered by Motes on April 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP