Find words whose first and last three letters are equal: Difference between revisions
Find words whose first and last three letters are equal (view source)
Revision as of 17:57, 4 September 2021
, 2 years ago→{{header|Racket}}
Line 471:
testes
</pre>
=={{header|Racket}}==
<lang racket>#lang racket
(define ((prefix-and-suffix-match? len) str)
(let ((l (string-length str)))
(and (>= l (* 2 len))
(string=? (substring str 0 len)
(substring str (- l len))))))
(module+ main
(filter (prefix-and-suffix-match? 3) (file->lines "../../data/unixdict.txt")))</lang>
{{out}}
<pre>'("antiperspirant" "calendrical" "einstein" "hotshot" "murmur" "oshkosh" "tartar" "testes")</pre>
=={{header|Raku}}==
|