In the absence of a full-fledged tutorial, I am teaching myself to program in the Factor language by writing a bunch of functions that I will eventually use in command-line scripts.
One common operation I like to perform is to change the case of names of files contained in a given directory to uppercase or lowercase. I wrote the following code to perform this operation in Factor:
USING: fry kernel io.directories sequences unicode.case ;
IN: util.directories
: move-each-directory-file>lower ( pathname -- )
[ dup >lower ] move-each-directory-file ;
: move-each-directory-file>upper ( pathname -- )
[ dup >upper ] move-each-directory-file ;
: each-directory-file ( pathname quot -- )
'[ [ @ ] each ] with-directory-files ; inline
: move-each-directory-file ( pathname quot -- )
'[ @ move-file ] each-directory-file ; inline
I have tried to factor as much code as possible into a reusable vocabulary. I look forward to suggestions for improvement.