Comment detail

LL Golf Hole 4 - 文章から単語の索引を作る (Nested Flatten)

This comment is reply for 7070 koguro: まだ無駄があった (277 bytes)。(LL Golf Hole 4 - 文章から単語の索引を作る ). Go to thread root.

もっと素直にやっても結構短くなるみたいですよ(262bytes)。

1
(use file.util)(use util.list)(use srfi-13)(do((t(make-hash-table 'string=?))(ls(file->string-list(car *argv*))(cdr ls))(n 1 (+ n 1)))((null? ls)(print(hash-table->alist t)))(dolist(w(string-split(car ls)#[\W]))(hash-table-push! t (string-downcase w) n)))

素直にstdinから読んで146B。

1
(let([t(hash-table'equal?)][n 1])(guard,,(hash-table-map t print)(while(map(cut hash-table-push! t <> n)(string-split(read-line)#[\W]))(inc! n))))

Index

Feed

Other

Link

Pathtraq

loading...