Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.69 KB | None | 0 0
  1. (define (set-sod-array! target-board offset line)
  2.     (let loop ((line line) (target-board target-board) (count offset))
  3.         (if (not (null? line))
  4.             (begin
  5.                 (vector-set! target-board count
  6.                     (if (eq? #\space (car line))
  7.                         0
  8.                         (car line)))
  9.                 (loop (cdr line) target-board (+ count 1)))
  10.             count)))
  11.  
  12. (define (read-sod-file path)
  13.     (let ((file (open-input-file path))
  14.           (board (make-vector 81)))
  15.         (let read-while ((file file) (count 0))
  16.             (let ((line (read-line file)))
  17.                 (if (not (eof-object? line))
  18.                     (read-while file (set-sod-array! board count (string->list line)))
  19.                     (close-input-port file))))
  20.         board))
  21.  
  22. (define (foo target-board)
  23.     (display target-board))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement