slurp-backward-into
function
rewrite-clj.paredit/slurp-backward-into
(slurp-backward-into [zloc] [zloc opts])Returns `zloc` with node to the left 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!