如何使用部分应用引用来重构代码?

时间:2015-03-30 20:39:36

标签: factor-lang

如何使用现有的组合器重构此代码,以便正则表达式将成为部分应用的参数,并且结果引用将具有与ls (x -- )相同的堆栈效果?

USING: io.directories locals sequences accessors math 
  prettyprint kernel io.files.info io.directories.hierarchy 
  combinators.short-circuit regexp
  ;
IN: flac

:: job ( step path -- ) 
     path 
     [ [ step call ] each ]
     with-directory-entries
     ; inline
:: lsc ( x c -- ) x c call [ x . ] when ; inline
:: ls ( x -- )
     x 
     [ { 
         [ directory? ] 
         [ name>> directory-tree-files 
           [ ".*[.]flac" <regexp> matches? ] 
           filter length 0 = 
         ]
       } 
       1&&
     ] 
     lsc
     ;

0 个答案:

没有答案