slurp-forward-into
function
rewrite-clj.paredit/slurp-forward-into
(slurp-forward-into [zloc] [zloc opts])Return `zloc` with node to the right of nearest eligible sequence slurped into that sequence else `zloc` unchanged.
Optional `opts` specify:
- `:from`
- `:parent` (default) starts search from parent of `zloc` then upward
- `:current` starts search from `zloc` then upward to allow slurping into empty sequences
Generic behavior:
- `[1 [2 |3 4] 5 6] => [1 [2 |3 4 5] 6]` Slurp into parent
- `[[[|1 2]]] 3 => [[[|1 2]] 3]` Slurp into ancestor
With `:from :current`:
- `[[1 |[]]] 2 3 => [[1 |[]] 2] 3` Slurp into ancestor (same as generic behavior)
- `[1 |[]] 2 3 => [1 |[] 2] 3` Slurp into parent
- `[1 |[] 2] 3 => [1 |[2]] 3` Slurp into current empty sequence
- `[1 |[2]] 3 => [1 |[2] 3]` Slurp into parent
- `[1 |[2] 3] => [1 |[2 3]]` Slurp into current non-empty sequence
With `:from :parent` (default):
- `[[1 |[]]] 2 3 => [[1 |[]] 2] 3` Slurp into ancestor (same as generic behavior)
- `[1 |[]] 2 3 => [1 |[] 2] 3` Slurp into parent
- `[1 |[] 2] 3 => [1 |[] 2 3]` Slurp into parent
Examples
No examples yet. Be the first to add one!