lambdaway
::
find_in_unixdict
4
|
list
|
login
|
load
|
|
_h1 [[maxorderedwords]] | find in unixdict _p Following [[rosettacode.org|https://rosettacode.org/wiki/Find_words_whose_first_and_last_three_letters_are_equal]], using the dictionary {b unixdict.txt} find the words whose first and last three letters are equal. The length of any word shown should have a length > 5. The output must be: {pre antiperspirant calendrical einstein hotshot murmur oshkosh tartar testes } {require lib_UNIXDICT} _h2 code _p The {b unixdict.txt} has been loaded from [[https://web.archive.org|https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt]] and stored in a wiki page, {b lib_UNIX.DICT}, from which it can be {b required} on demand in any other one. Note that the name {b UNIX.DICT} is broken to avoid displaying its content in this page. {prewrap '{require. lib_UNIX.DICT} // the true require uses the unbroken name '{def look {lambda {} {S.replace \s by {div} in {S.map {lambda {:w} {if {and {> {W.length :w} 5} {W.equal? {W.slice 0 3 :w} {W.slice -3 {W.length :w} :w} }} then :w else}} {S.replace else by el.se in UNIX.DICT}} }}} -> {def look {lambda {_} {S.replace \s by {div} in {S.map {lambda {:w} {if {and {> {W.length :w} 5} {W.equal? {W.slice 0 3 :w} {W.slice -3 {W.length :w} :w} }} then :w else}} {S.replace else by el.se in UNIXDICT}} }}} '{look} -> {look _} } _p Note: Due to a "weakness" of the {b '{if then else}} special form, where the {b else} separator is not protected, every occurences of the string "else" in the input text must be replaced by some "broken word" before the search, and restored after if necessary.
lambdaway v.20211111