]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/strings-lib/lib.factor
Conflict resolution
[factor.git] / unmaintained / strings-lib / lib.factor
1 USING: math math.ranges arrays sequences kernel random splitting
2 strings unicode.case ;
3 IN: strings.lib
4
5 : >Upper ( str -- str )
6     dup empty? [ unclip ch>upper prefix ] unless ;
7
8 : >Upper-dashes ( str -- str )
9     "-" split [ >Upper ] map "-" join ;
10
11 : lower-alpha-chars ( -- seq )
12     CHAR: a CHAR: z [a,b] ;
13
14 : upper-alpha-chars ( -- seq )
15     CHAR: A CHAR: Z [a,b] ;
16
17 : numeric-chars ( -- seq )
18     CHAR: 0 CHAR: 9 [a,b] ;
19
20 : alpha-chars ( -- seq )
21     lower-alpha-chars upper-alpha-chars append ;
22
23 : alphanumeric-chars ( -- seq )
24     alpha-chars numeric-chars append ;
25
26 : random-alpha-char ( -- ch )
27     alpha-chars random ;
28
29 : random-alphanumeric-char ( -- ch )
30     alphanumeric-chars random ;
31
32 : random-alphanumeric-string ( length -- str )
33     [ random-alphanumeric-char ] "" replicate-as ;