Welcome to the CHICKEN Scheme pasting service

Index creation - partial conversion to CHICKEN pasted by arthurmaciel on Fri Apr 17 02:42:00 2015

(use irregex posix srfi-13 utils)

(define file "your-file")
(define index "index")

; bos = beggining of string
(define byte-num-regexp '(: bos (* num)))

(define (get-byte-offset line)
  (car (irregex-extract byte-num-regexp line)))

(define (grep-output file)
  (call-with-values (lambda () (process (string-append "grep -b '' " file)))
    (lambda (in-port _ _)
      (read-all in-port))))

(define (make-index grep-output)
  (let ((index-fileno (file-open index (+ open/wronly open/append open/creat))))
    (with-input-from-string grep-output
     (lambda ()
       (let loop ((line (read-line)))
	 (unless (eof-object? line)
	   (file-write index-fileno (string-append (string-pad (get-byte-offset line) 16) "\n"))
	   (loop (read-line))))))))

(define (start-index)
  (make-index (grep-output file)))

Index creation - to pinkiesOut added by arthurmaciel on Fri Apr 17 19:17:29 2015

(use posix srfi-13)

(define file "test-file2")
(define index "index")

(define (get-byte-offset line)
  (car (string-split line ":" #t)))

(define (make-index file)
  (call-with-values (lambda () (process (string-append "grep -b '' " file)))
    (lambda (in-port _ _)
      (let ((index-fileno (file-open index (+ open/wronly open/creat))))
	(let loop ((line (read-line in-port)))
	 (unless (eof-object? line)
	   (file-write index-fileno (string-append (string-pad (get-byte-offset line) 16) "\n"))
	   (loop (read-line in-port))))))))

(make-index file))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the procedure that returns the cdr of a car?
Visually impaired? Let me spell it for you (wav file) download WAV