Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 23 lines (17 sloc) 0.679 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
;; how much code have you written?
#lang scheme/base

(require "util.scm")

(provide loc)

;; counts all lines except for comment lines and blank lines
(define (loc #:comment-chars (comment-chars (list #\;)) . filenames)
  (fold + 0
        (map (lambda (filename)
               (file-line-fold
                (lambda (line-str total-loc)
                  (let ((trimmed (string-trim-both line-str #\space)))
                    (cond ((string=? trimmed "") total-loc)
                          ((memq (string-ref trimmed 0) comment-chars) total-loc)
                          (else (+ 1 total-loc)))))
                0
                filename))
             filenames)))


Something went wrong with that request. Please try again.