Created
March 26, 2015 14:47
-
-
Save okuoku/7f5b3fa0d4dbd0230b9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import (rnrs) | |
(only (srfi :1) lset-difference) | |
(srfi :8) | |
(shorten) | |
(yuni util files) | |
(yuni text tabular)) | |
(define (filt-r7 sexp) (filter (lambda (e) (pair? (car e))) sexp)) | |
(define (genall dic) | |
(define syms* (map cdr dic)) | |
(apply append syms*)) | |
(define (douniq lis) | |
(define ht (make-eq-hashtable)) | |
(reverse | |
(fold-left (^[cur e] | |
(cond ((hashtable-ref ht e #t) | |
(hashtable-set! ht e #f) | |
(cons e cur)) | |
(else cur))) | |
'() lis))) | |
(define r6 (file->sexp-list "r6-symbols.scm")) | |
(define r7 (filt-r7 (file->sexp-list "r7-symbols.scm"))) | |
(define r6-ht (make-eq-hashtable)) | |
(define r7-ht (make-eq-hashtable)) | |
(define r6-all (douniq (genall r6))) | |
(define r7-all (genall r7)) | |
(define (in-r7? sym) (hashtable-ref r7-ht sym #f)) | |
(define (setht! ht dic) | |
(for-each (^(lib) | |
(let ((libname (car lib)) | |
(sym* (cdr lib))) | |
(for-each (^(sym) | |
(unless (hashtable-ref ht sym #f) | |
(hashtable-set! ht sym libname))) | |
sym*))) | |
dic)) | |
(define (entry sym) | |
(list (hashtable-ref r6-ht sym "---") | |
sym | |
(hashtable-ref r7-ht sym "---"))) | |
;; setup ht | |
(setht! r6-ht r6) | |
(setht! r7-ht r7) | |
(receive (common r6ex) (partition in-r7? r6-all) | |
(display (tabular->string | |
`(#("R6LibName~sR" "Sym~sC" "R7LibName~sL") | |
,@(map entry common) | |
,@(map entry r6ex) | |
,@(map entry (lset-difference eq? r7-all r6-all)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment