Questions tagged [remove-if]

Common Lisp 'remove-if' function.

Common Lisp 'remove-if' function.

It's signature is:

remove-if test sequence &key from-end start end count key => result-sequence

CLHS: remove-if

201 questions
5
votes
3 answers

Remove all elements from array greater than n

I'm beginner in programming. Something is giving me trouble to code. Suppose, I've an array. int Array[] = {3,6,9,5,10,21,3,25,14,12,32,41,3,24,15,26,7,8,11,4}; I want to remove all elements which are greater than 9. How can I do this?
Xrin
  • 53
  • 1
  • 4
5
votes
4 answers

std::remove_if not working properly

Here my code. I want remove from vector all elements with successfully called method 'release'. bool foo::release() { return true; } // ... vector vec; // ... remove_if(vec.begin(), vec.end(), [](foo & f) { return f.release() == true;…
Alex Shul
  • 500
  • 7
  • 22
4
votes
6 answers

How to delete a particular value from the whole dataframe in R?

I have a data frame that is z-score converted. I want to delete from the data frame (and convert to NA) only those values that are higher or equal to 4, without dropping any row or column. I would appreciate an answer. Best
lotus
  • 87
  • 5
4
votes
3 answers

How do I remove all elements except one in jQuery?

I'm using jQuery 1.12. After clicking on a TD, I want to remove all elements within it except the one with class "savedBlock", so I tried $(elt).closest('td').find('.savedBlock').show() $(elt).closest('td').not('.savedBlock').remove()…
user7055375
4
votes
3 answers

using remove_if for a map container

I was trying to use remove_if template for a map container but I am getting compiler error for the template argument. I am unable to understand why. int main() { map intmap; intmap[1] = 1; intmap[2] = 2; intmap[3] = 3; …
4
votes
1 answer

Remove list from lists in list if length

I have this list: a <- list(list(c("sam1", "control"), c("sam1", "latanoprost free acid", "GSM6683", "GSM6684"), c("sam1", "prostaglandin F2alpha", "GSM6687", "GSM6688")), list(c("sam2", "control"), c("sam2", "latanoprost free acid", "GSM6681",…
charisz
  • 302
  • 4
  • 12
4
votes
2 answers

remove_if with boost::bind is slow

I have a std::list of classes and want to remove entries that are marked for delete. I am using std::remove_if and erase. class MyClass { bool isDone(MyData& myData) { return myData.isDone(); } void…
Ant
  • 1,668
  • 2
  • 18
  • 35
4
votes
1 answer

Trouble with remove_if (it stops removing after a few removals)

The code below wants to take a string and output only lowercase letters from the English alphabet. string simplifyString(string word) { word.erase(remove_if(word.begin(), word.end(), [](char letter){return !isalpha(letter);})); …
user904963
  • 1,520
  • 2
  • 15
  • 33
3
votes
4 answers

How to remove multiple objects in List by id?

I have a class as below class MyClass { public string id { get; set; } public string data { get; set; } } I have an array of ids I need to remove: List myObjArray = new List; myClass myObj1 = new myClass { id = "1", data…
noobDev
  • 99
  • 3
  • 8
3
votes
2 answers

var [][] array remove specific words

I got a little Problem. I have a .csv with "NaN" values and doubles (0.6034 for example) and I am trying to read just the doubles of the CSV into an array[y][x]. Currently, i read the whole .csv, but I can not manage to remove all "NaN" values…
christian890
  • 147
  • 1
  • 12
3
votes
2 answers

Windows Batch File : Convert Structures into Single Lines Strings

This hard task I need to do as a batch file, it's not the most difficult to do with C but in DOS is a hell (at least for me!) I need to convert a structure to a single var (string) to be able to convert them into that structure again inside my…
Hajas
  • 87
  • 7
3
votes
2 answers

How to use the method "removeIf" using a Predicate in a ArrayBlockingQueue

I have the following classes: WorkerTask.java public interface WorkerTask extends Task { // Constants public static final short WORKERTASK_SPIDER = 1; public static final short WORKERTASK_PARSER = 2; public static final short…
3
votes
2 answers

remove_if based on vector index with a functor

This question showed how to use erase/remove_if based on vector indices using a function predicate. This works well the first time the function is called but because the local static variable maintains state, on the next call to a different vector…
confusedCoder
  • 223
  • 1
  • 10
3
votes
1 answer

In c++, is it safe to use std::numeric_limits::max() as a special "flag"?

Given std::vector a; std::vector ind; where ind is 1sorted in ascending order. I want to do the equivalent of the following: for (auto it=ind.rbegin();it!=ind.rend();it++) a.erase(a.begin() + *it); I came up with this: for (auto…
Jens
  • 153
  • 1
  • 8
3
votes
2 answers

remove tag but keep content between tag if matched string

I have file php: include string show_ads_1 and other string 1