Project Euler 22を解く感じ
(add-load-path "." :relative) (use text.csv) (define *names-text* "./problem-22/names.txt") ;;適当なパスに放り込んだnames.txt (let1 num 0 (fold (lambda (x y) (+ (* (inc! num) (name->score x)) y)) 0 (sort (with-input-from-file *names-text* (cut (make-csv-reader #\,))) (lambda (x y) (string<? x y))))) (define (name->score name) (fold (lambda (x y) (+ (- (char->integer x) 64) y)) 0 (string->list name)))
ざっくり解いたけど、これ以上良い感じにかけなかった。