aboutsummaryrefslogtreecommitdiff
path: root/doc/group.md
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-06-20 08:10:31 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-06-20 08:10:31 -0400
commit617d05b2cbb07e2778411b889914eecc156c6d79 (patch)
treeab09f79fa34cde5fd6af55c8f1c67e4fe7cc6e57 /doc/group.md
parent7ee066159ac2a60fffc3162cd31d35ce73cfd623 (diff)
Use vector reduce in documentation
Diffstat (limited to 'doc/group.md')
-rw-r--r--doc/group.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/group.md b/doc/group.md
index 6451d678..c149716c 100644
--- a/doc/group.md
+++ b/doc/group.md
@@ -168,14 +168,14 @@ In other cases, we might want to split on spaces, so that words are separated by
However, trailing spaces are ignored because Group never produces trailing empty groups (to get them back we would use a dummy final character in the string). To avoid empty words, we should increase the word index only once per group of spaces. We can do this by taking the prefix sum of a list that is 1 only for a space with no space before it. To make such a list, we can use the [Windows](windows.md) function. We will extend our list with an initial 1 so that leading spaces will be ignored. Then we take windows of the same length as the original list: the first includes the dummy argument followed by a shifted copy of the list, and the second is the original list. These represent whether the previous and current characters are spaces; we want positions where the previous wasn't a space and the current is.
- ≍⟜(<´≠↕1∾⊢) ' '=" string with spaces " ⍝ All, then filtered, spaces
+ ≍⟜((<´<˘)≠↕1∾⊢) ' '=" string with spaces " ⍝ All, then filtered, spaces
1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0
- ≍⟜(⊢-˜¬×+`∘(<´≠↕1∾⊢))' '=" string with spaces " ⍝ More processing
+ ≍⟜(⊢-˜¬×+`∘((<´<˘)≠↕1∾⊢))' '=" string with spaces " ⍝ More processing
1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1
¯1 ¯1 0 0 0 0 0 0 ¯1 1 1 1 1 ¯1 ¯1 2 2 2 2 2 2 ¯1 ¯1 ¯1
- ' '((⊢-˜¬×+`∘(<´≠↕1∾⊢))∘=⊔⊢)" string with spaces " ⍝ Final result
+ ' '((⊢-˜¬×+`∘((<´<˘)≠↕1∾⊢))∘=⊔⊢)" string with spaces " ⍝ Final result
[ [ string ] [ with ] [ spaces ] ]