3 ms·
The lisp code has a few problems. It's using a regex library that's only available in clisp (I think), it's not using the standard input like the other examples
by kroger 16y ago
The lisp code has a few problems. It's using a regex library that's
only available in clisp (I think), it's not using the standard input
like the other examples, and having two functions named has-suffix and
has_suffix is no good. Also, it'll return an error if the string is
shorter than the suffix.
In the following example I'm using the portable
http://www.cliki.net/SPLIT-SEQUENCE http://www.cliki.net/SPLIT-SEQUENCE to split the words:
(defun endswith (string suffix)
(let ((size (- (length string) (length suffix))))
(unless (minusp size)
(equalp (subseq string size) suffix))))
(loop for line = (read-line *standard-input* nil) while line do
(loop for word in (split-sequence #\Space line) do
(if (endswith word "ing")
(write-line word))))
It's still wordier than python, though.