I am writing a simple function return similar words.
Clear[similarWords]
similarWords[string_]:=Nearest[WordList[],string]
I want to add another argument n which is optional. When it presents, it controls the number of words returns.
Clear[similarWords]
similarWords[string_,n_:???]:=Nearest[WordList[],string,n]
But the problem is, what should I put it ???. I cannot figure it out.
The only way I can come up is
Clear[similarWords]
similarWords[string_,n_:-1]:=If[n==-1,Nearest[WordList[],string],Nearest[WordList[],string,n]]
Is there a neater way?
n___? or more precisely but longer:n:(_|PatternSequence[]). – Kuba Sep 09 '16 at 11:12similarWords[string_, n_: 1] := Nearest[WordList[], string, n]? – corey979 Sep 09 '16 at 11:21Nearest[WordList[], "suprise"]– matheorem Sep 09 '16 at 11:27similarWords[string_,n___]:=blabla– Vahagn Tumanyan Sep 09 '16 at 11:48