Skip to content

Instantly share code, notes, and snippets.

@samth
Forked from mbertheau/hangul-reading.rkt
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samth/44a29fb1b746f7d77385 to your computer and use it in GitHub Desktop.
Save samth/44a29fb1b746f7d77385 to your computer and use it in GitHub Desktop.
#lang racket
(define hangul-data-file "src/racket-unihan/Unihan_Readings.txt")
(define-values (_ r) (call-with-input-file hangul-data-file
(lambda (in)
(for/lists (lines) ([l (in-lines in)]
#:unless (eq? '#\# (string-ref l 0))
#:break (= (length lines) 30))
l))))
(define-values (_ r2) (call-with-input-file hangul-data-file
(lambda (in)
(let loop ([c 0])
(define l (read-line in))
(if (= c 30)
null
(if (eq? '#\# (string-ref l 0))
(loop c)
(cons l (loop (add1 c)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment