5 deleted 2 characters in body
source | link

Update: You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Or ReplaceAll

a = Range[10];
a /. Alternatives @@ Drop[a, {4, 6}]4;;6] -> b

{b, b, b, 4, 5, 6, b, b, b, b}

Original answer: Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

Update: You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Or ReplaceAll

a = Range[10];
a /. Alternatives @@ Drop[a, {4, 6}] -> b

{b, b, b, 4, 5, 6, b, b, b, b}

Original answer: Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

Update: You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Or ReplaceAll

a = Range[10];
a /. Alternatives @@ Drop[a, 4;;6] -> b

{b, b, b, 4, 5, 6, b, b, b, b}

Original answer: Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

4 deleted 8 characters in body
source | link

Update: You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Or ReplaceAll

a = Range[10];
a /. Alternatives @@ Drop[a, {4, 6}] -> b

{b, b, b, 4, 5, 6, b, b, b, b}

Original answer: Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Update: You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Or ReplaceAll

a = Range[10];
a /. Alternatives @@ Drop[a, {4, 6}] -> b

{b, b, b, 4, 5, 6, b, b, b, b}

Original answer: Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

3 deleted 8 characters in body
source | link

Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

AlsoYou can also try MapAt:

a = Range[10];
Fold[MapAt[ba &,= ##]MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

Also

a = Range[10];
Fold[MapAt[b &, ##] &, a, {;; 3, 7 ;;}]

{b, b, b, 4, 5, 6, b, b, b, b}

Try Drop:

Drop[Range @ 10, {4, 6}]

{1, 2, 3, 7, 8, 9, 10}

Drop[Range @ 10, 4 ;; 6]

{1, 2, 3, 7, 8, 9, 10}

Drop[CharacterRange["a", "j"], {4, 6}]

{"a", "b", "c", "g", "h", "i", "j"}

You can also try MapAt:

a = Range[10];
a = MapAt[b &, a, {{;; 3}, {7 ;;}}]

{b, b, b, 4, 5, 6, b, b, b, b}

2 added 112 characters in body
source | link
1
source | link