Jump to content

Odd words: Difference between revisions

Realize in F#
(Realize in F#)
Line 375:
</pre>
 
==={{header|F_Sharp|F#}}==
<lang fsharp>
// Odd words: Nigel Galloway. June 9th., 2021
let dict=seq{use n=System.IO.File.OpenText("unixdict.txt") in while not n.EndOfStream do yield n.ReadLine()}|>Seq.filter(fun n->n.Length>4)|>List.ofSeq
let fN g=let n=g|>String.mapi(fun n g->if n%2=0 then g else ' ')|>String.filter((<>)' ') in match List.contains n dict with true->Some(n,g) |_->None
dict|>Seq.filter(fun n->n.Length>6)|>Seq.choose fN|>Seq.iter(fun(n,g)->printfn "%s -> %s" g n)
</lang>
{{out}}
<pre>
barbarian -> brain
childbear -> cider
corrigenda -> cried
gargantuan -> grata
headdress -> hades
palladian -> plain
propionate -> point
salvation -> slain
siltation -> slain
slingshot -> sight
statuette -> saute
supersede -> spree
supervene -> spree
terminable -> trial
</pre>
=={{header|Factor}}==
This is basically the same program as https://rosettacode.org/wiki/Alternade_words#Factor. <code><evens></code> is a virtual sequence representing the (zero-based) even indices of the input sequence, which this task calls the odd indices.
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.