On Wed, 2013-01-23 at 19:28 +0800, Nala Ginrut wrote: > As I talked with Andy, we may add a feature to list all available > languages. And if users add a new language to the %load-path, they may > see it listed out. Besides, this feature could be used in 'guild > compile' to detect all the language available. > > Attached is a proc named 'get-all-available-languages', it'll scan all % > load-path and list the union of the languages available. > > Please review it. > If accepted, I'll format a patch into (ice-9 command-line). > > Thanks!
I think Regular Expression would better choice ;-p New patch attached.
(use-modules (ice-9 ftw) (srfi srfi-1)) (define (not-inner-lang? str) (not (string-match "glil|glil\\.scm|assembly|assembly\\.scm|bytecode|objcode\\.scm|objcode|tree-il|tree-il\\.scm|value|\\.\\.|\\." str))) (define (get-all-available-languages) (let lp((rest (map (lambda (x) (string-append x "/language")) %load-path)) (result '())) (cond ((null? rest) (apply lset-union string=? result)) (else (let ((ll (scandir (car rest) not-inner-lang?))) (lp (cdr rest) (if ll (cons ll result) result)))))))