3 ms·
out of curiosity today i reimplemented this $ grep ' [qwertyuiop]*$' ~/wordlist | perl -lane 'print length $F[1], " $F[1]"' | sort -n in common lisp (
by kragen 3y ago
out of curiosity today i reimplemented this
$ grep ' [qwertyuiop]*$' ~/wordlist | perl -lane 'print length $F[1], " $F[1]"' | sort -n
in common lisp
(defconstant *wordlist*
(with-open-file (in #P"~/wordlist")
(loop for line = (read-line in nil)
while line
for p = (position #\space line :from-end t)
collect (list (parse-integer (subseq line 0 p))
(subseq line (1+ p))))))
(defconstant *topwords*
(let ((w (loop for (freq word) in *wordlist*
if (loop for c across word always (find c "qwertyuiop"))
collect word)))
(sort w #'< :key #'length)))
those last four lines of code seem very acceptable to me but not really competitive with the unix approach for interactive experimentation
http://canonical.org/~kragen/sw/dev3/handwords.lisp http://canonical.org/~kragen/sw/dev3/handwords.lisp
- lispm 3y agoThe standard says that WHILE can't appear before FOR in LOOP. (parse-integer (subseq line 0 p)) is shorter (parse-integer "12345678" :end 3)