TOC < Back Next > Updated: 6-Feb-2009 Edit History

# REBOL 3 Concepts: Series: Modification Refinements

Pending Revision

This document was written for R2 and has yet to be revised for R3.

The change, insert, and remove functions can take additional refinements to modify their operation.

## Part

The /part refinement accepts a count or a position in the series and uses it to limit the effect of the function.

For example, using the following series:

```str: "abcdef"
blk: [1 2 3 4 5 6]```

you can change part of str and blk using change/part:

```change/part str [1 2 3 4] 3
probe str
1234def```
```change/part blk "abcd" 3
probe blk
["abcd" 4 5 6]```

You can insert part of a series into the tail of str and blk using insert/part.

```insert/part tail str "-ghijkl" 4
probe str
1234def-ghi```
```insert/part tail blk ["--" 7 8 9 10 11 12] 4
probe blk
["abcd" 4 5 6 "--" 7 8 9]```

To remove part of the str and blk series, use remove/part. Note how find is used to obtain the series position:

```remove/part (find str "d") (find str "-")
probe str
1234-ghi```
```remove/part (find blk 4) (find blk "--")
probe blk
["abcd" "--" 7 8 9]```

## Only

The /only refinement changes or inserts a block as a block, rather than its individual values.

Examples:

`blk: [1 2 3 4 5 6]`

You can replace the 2 in blk with the block [a b c] and insert the block [\$1 \$2 \$3] at the position of the 5.

```change/only (find blk 2) [a b c]
probe blk
[1 [a b c] 3 4 5 6]```
```insert/only (find blk 5) [\$1 \$2 \$3]
probe blk
[1 [a b c] 3 4 [\$1.00 \$2.00 \$3.00] 5 6]```

## Dup

The /dup refinement changes or inserts a value a specified number of times.

Examples:

```str: "abcdefghi"
blk: [1 2 3 4 5 6]```

You can change the first four values in a string or block series to an asterisk () with:

```change/dup str "*" 4
probe str
****efghi```
```change/dup blk "*" 4
probe blk
["*" "*" "*" "*" 5 6]```

To insert a dash (-) four times before the last value in a string or block:

```insert/dup (back tail str) #"-" 4
probe str
****efgh==-i```
```insert/dup (back tail blk) #"-" 4
probe blk
["*" "*" "*" "*" 5 #"-" #"-" #"-" #"-" 6]```

 TOC < Back Next > Feedback Admin