2

What is a good way to remove a specific item in a sequence?

I want to remove "b" from the sequence ("a", "b", "c") for example.

("a", "b", "c")
-> do something
-> ("a", "c")

What I know does work is to split the sequence in two and then glue them back together but I would like to know if there are nicer solutions.

line-o
  • 1,885
  • 3
  • 16
  • 33

3 Answers3

2

How about $seq[. != 'b'] where $seq contains your sequence, naturally.

Norm
  • 866
  • 1
  • 7
  • 16
1

$seq[not(. eq 'b')], i.e., return items in the sequence, except for values of b. This approach avoids some of the vagaries of !=.

jdk
  • 111
  • 5
0

I ended up using ('a', 'b', 'c')[. ne 'b']

line-o
  • 1,885
  • 3
  • 16
  • 33