]> gitweb.factorcode.org Git - factor.git/commitdiff
tokencase: simplify
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 4 May 2023 22:34:23 +0000 (15:34 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 4 May 2023 22:34:23 +0000 (15:34 -0700)
extra/tokencase/tokencase.factor

index 19c919f6ff6324d516028b999717d517214de912..a6b4c678e6bfcce6ab58e70b07340548d55e0c33 100644 (file)
@@ -8,16 +8,14 @@ IN: tokencase
 <PRIVATE
 
 : case-index ( str -- i/f )
-    dup [ lower? ] find drop [
-        over [ lower? not ] find-from drop
-        [ nip ] [ length ] if*
-    ] [ length ] if* ;
+    dup [ lower? ] find [
+        swap [ lower? not ] find-from drop
+    ] [ nip ] if ;
 
 : split-case ( str -- words )
     >graphemes [ dup empty? not ] [
-        dup case-index
-        [ cut-slice swap ]
-        [ f 0 rot [ length ] keep <slice> ] if* concat
+        dup [ case-index ] [ length or ] bi
+        cut-slice swap concat
     ] produce nip ;
 
 : split-tokens ( str -- words )